[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/demo irregu3.py
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx/demo irregu3.py |
Date: |
Fri, 01 Nov 2002 14:15:31 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/11/01 14:15:31
Modified files:
gfx/demo : irregu3.py
Log message:
Finished fragment program profile
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.38 gzz/gfx/demo/irregu3.py:1.39
--- gzz/gfx/demo/irregu3.py:1.38 Fri Nov 1 10:42:34 2002
+++ gzz/gfx/demo/irregu3.py Fri Nov 1 14:15:31 2002
@@ -9,7 +9,6 @@
edgelodbias = 0
texscale = 1
use_texture = 0
-use_stencil = 1
matrices = [ "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1",
"4 0 0 0.005 0 1 0 0 0 0 1 0 0 0 0 1" ]
@@ -56,26 +55,47 @@
global tex
global texenv_inner, texenv_outer, alphalevel, w0, w1
global colmap0, colmap1, angles
- global using_shader, using_secondary_color, using_multitex
+ global using_fragprog, using_shader, using_secondary_color, using_multitex
+ using_fragprog = 0
using_shader = 0
using_secondary_color = 0
using_multitex = 0
if profile == "NV_PROG":
+ using_fragprog = 1
+
radius = 2
dh = [ sqrt(radius**2 - d**2) for d in range(0,radius+1) ]
+ prog_inner = GL.createProgram("""!!FP1.0
+ # f[TEX0].xy texture coordinates
+ # f[TEX2].xy texture HI and LO component weights
+ # f[TEX2].w displacement (added to the weighted texture value)
+
+ # Read texture
+ TEX R0, f[TEX0], TEX0, 2D;
+
+ # Weight, add displacement, and use as output color
+ DP4 o[COLR], R0, f[TEX2];
+ END
+ """)
+
code = """!!FP1.0
# Inputs:
- # f[TEX0].xy texture coordinates
- # f[TEX0].z displacement
+ # f[TEX0].xy texture coordinates
# f[TEX1].xy one-pixel difference of texcoords in the 1D slice
- # f[TEX1].z one-pixel difference of displacement
+ # f[TEX1].w one-pixel difference of displacement
- # Read texture and add dh[0] value multiplied by R0.z
- TEX R1, f[TEX0], TEX0, 2D;
- MAD R1, %s, f[TEX1].z, R1;
+ # f[TEX2].xy texture HI and LO component weights
+ # f[TEX2].w displacement (added to the weighted texture value)
+
+ # Read texture, weight, and add displacement
+ TEX R0, f[TEX0], TEX0, 2D;
+ DP4 R0, R0, f[TEX2];
+
+ # Add dh[0] value multiplied by f[TEX1].w
+ MAD R0, %s, f[TEX1].w, R0;
MOV R2, f[TEX0];
MOV R3, f[TEX0];
@@ -83,36 +103,59 @@
for i in range(1,len(dh)):
code += """
- # Read texture at +/- r and take the maximum
+ # Read texture at +/- r
ADD R2, R2, f[TEX1];
ADD R3, R3, -f[TEX1];
TEX R4, R2, TEX0, 2D;
TEX R5, R3, TEX0, 2D;
+
+ # Weight, add displacement, and take the maximum
+ DP4 R4, R4, f[TEX2];
+ DP4 R5, R5, f[TEX2];
MAX R4, R4, R5;
"""
if dh[i]:
code += """
- # Add dh[r] value multiplied by f[TEX1].z
- MAD R4, %s, f[TEX1].z, R4;
+ # Add dh[r] value multiplied by f[TEX1].w
+ MAD R4, %s, f[TEX1].w, R4;
""" % dh[i]
code += """
- # Store maximum found in R1
- MAX R1, R1, R4;
+ # Store the maximum found in R0
+ MAX R0, R0, R4;
"""
code += """
- # Add displacement and use as output color
- ADD o[COLR], R1, f[TEX0].z;
-
+ MOV o[COLR], R0;
END
"""
- global fragprog
- fragprog = GL.createProgram(code)
-
- if profile == "NV_SHAD":
+ prog_outer = GL.createProgram(code)
+
+
+
+ texenv_inner = """
+ BindProgramNV FRAGMENT_PROGRAM_NV %s
+ Enable FRAGMENT_PROGRAM_NV
+ """ % prog_inner.getProgId()
+
+ texenv_outer = """
+ BindProgramNV FRAGMENT_PROGRAM_NV %s
+ Enable FRAGMENT_PROGRAM_NV
+ """ % prog_outer.getProgId()
+
+
+ alphalevel = 1
+ w0,w1 = 1,1
+ def colmap0(dotvec): return (1,1,1)
+ def colmap1(dotvec): return (1,1,1)
+
+ angles = 0
+ tex = ( getIrreguTex(2, "HILO_NV", "HILO_NV"),
+ )
+
+ elif profile == "NV_SHAD":
print "Using 2-vector HILO displacement texture with
GL_NV_texture_shader"
using_shader = 1
@@ -506,6 +549,25 @@
]
]
+ if using_fragprog:
+ dx = cos(angle)
+ dy = sin(angle)
+
+ m = texscale / (striplen * scale)
+ vec = (m * (x1 - x0),
+ m * (y1 - y0),
+ 0,
+ 1.0 / (scale * ripple_scale * texscale),
+ )
+
+ texcoords += [ [ vec, vec, vec, vec, ],
+ [ (dx,dy,0,1.5-.5*(dx+dy)),
+ (dx,dy,0,.5-.5*(dx+dy)),
+ (dx,dy,0,1.5-.5*(dx+dy)),
+ (dx,dy,0,.5-.5*(dx+dy)),
+ ]
+ ]
+
vec = [ 0 for i in range(0, angles) ]
if angles:
@@ -700,7 +762,7 @@
vs.map.put(getDListNocoords("ActiveTexture TEXTURE2"))
vs.map.put(GLRen.createTextureMatrix(), cs4)
vs.map.put(getDListNocoords("ActiveTexture TEXTURE0"))
- elif using_shader:
+ elif using_shader or using_fragprog:
vs.map.put(getDListNocoords("""
ActiveTexture TEXTURE2
PushAttrib TRANSFORM_BIT
- [Gzz-commits] gzz/gfx/demo irregu3.py,
Janne V. Kujala <=
- [Gzz-commits] gzz/gfx/demo irregu3.py, Janne V. Kujala, 2002/11/01
- [Gzz-commits] gzz/gfx/demo irregu3.py, Janne V. Kujala, 2002/11/01
- [Gzz-commits] gzz/gfx/demo irregu3.py, Janne V. Kujala, 2002/11/02
- [Gzz-commits] gzz/gfx/demo irregu3.py, Janne V. Kujala, 2002/11/05
- [Gzz-commits] gzz/gfx/demo irregu3.py, Janne V. Kujala, 2002/11/05
- [Gzz-commits] gzz/gfx/demo irregu3.py, Tuomas J. Lukka, 2002/11/08