]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/fft-normalmap-to-heightmap-soft.sh
Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic
[xonotic/xonotic.git] / misc / tools / fft-normalmap-to-heightmap-soft.sh
1 #!/bin/sh
2
3 i=$1
4 o=$2
5 f=$3
6 sca=$4
7 ofs=$5
8
9 s=`"${0%-soft.sh}" "$i" "$o" "$f"`
10 echo >&2 "$s"
11
12 # we want to map so that:
13 #   sca
14 #   med/avg -> ofs
15
16 realscale=`echo "$s" | grep ^Scale: | cut -d ' ' -f 2`
17 realmedian=`echo "$s" | grep ^Scaled-Med: | cut -d ' ' -f 2`
18
19 # we have to undo realscale, and apply sca instead
20 extrascale=`echo "$sca / $realscale" | bc -l`
21
22 # we want to make $realmedian + $ofs neutral
23
24 extraoffset=`echo "127.5 - 127.5 * ($realmedian + $ofs)" | bc -l`
25
26 echo "dpoffsetmapping - $extrascale $extraoffset"