diff options
author | Corbin Simpson <MostAwesomeDude@gmail.com> | 2008-07-18 11:06:34 -0700 |
---|---|---|
committer | Alex Deucher <alexdeucher@gmail.com> | 2008-08-25 06:19:04 -0400 |
commit | ca51f4f37e1dbf53bf7ffc0e8f612e9609e11209 (patch) | |
tree | 8ff86e7ed2e19f6d45b979fc80eeba8002b96ff6 /src/bicubic_table.py | |
parent | 1cf7a5494fa94e8d9f30f9b2905dfbe6d4faa445 (diff) |
Add bicubic texture table, as well as the script used to (re)generate it. To regenerate, just run "python bicubic_table.py > bicubic_table.h".
Diffstat (limited to 'src/bicubic_table.py')
-rwxr-xr-x | src/bicubic_table.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/bicubic_table.py b/src/bicubic_table.py new file mode 100755 index 00000000..45101173 --- /dev/null +++ b/src/bicubic_table.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +def texgen(): + + tex = [] + + for i in range(0,512,4): + + a = i / 512.0 + a2 = a ** 2 + a3 = a ** 3 + + w0 = 1 / 6.0 * (-a3 + 3 * a2 + -3 * a + 1) + w1 = 1 / 6.0 * (3 * a3 + -6 * a2 + 4) + w2 = 1 / 6.0 * (-3 * a3 + 3 * a2 + 3 * a + 1) + w3 = 1 / 6.0 * a3 + + tex.append(1 - (w1 / (w0 + w1)) + a) + tex.append(1 + (w3 / (w2 + w3)) - a) + tex.append(w0 + w1) + tex.append(w2 + w3) + + return tex + +def printrow(l, offset): + + seq = [ str(i) for i in l[offset:offset+4] ] + return "\t" + ", ".join(seq) + "," + +l = texgen() + +print "const float[] bicubic_tex = {" + +for i in range(0, 512, 4): + + print printrow(l, i) + +print "\tNULL }" |