gzz-commits
[Top][All Lists]
Advanced

[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: Tue, 29 Oct 2002 07:32:59 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/29 07:32:59

Modified files:
        gfx/demo       : irregu3.py 

Log message:
        Add dot4 interpolation profile for GL_NV_register_combiners

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.28 gzz/gfx/demo/irregu3.py:1.29
--- gzz/gfx/demo/irregu3.py:1.28        Tue Oct 29 06:53:52 2002
+++ gzz/gfx/demo/irregu3.py     Tue Oct 29 07:32:59 2002
@@ -23,12 +23,26 @@
 if (GL.hasExtension("GL_NV_register_combiners") and
     GL.hasExtension("GL_EXT_secondary_color")):
     profiles.append("NV_COMB")
+    profiles.append("NV_COMB4")
 
 if GL.hasExtension("GL_EXT_texture_env_dot3"):
     profiles.append("DOT3")
 
 profiles.append("STD")
 
+def getIrreguTex(components, iformat, format, scale = 1, bias = 0, angles = 0, 
invert = 0):
+
+    return getCachedTexture([texsize, texsize, 0, components, iformat, format, 
"irregu",
+                             ["radius", "2",
+                              "ripple_scale", str(ripple_scale),
+                              "scale", str(scale),
+                              "bias", str(bias),
+                              "angles", str(angles),
+                              "eps", ".125",
+                              "invert", str(invert),
+                              ]],
+                            shade_all_levels = 1)
+
 def init(profile):
     global tex, texinv
     global texenv_inner, texenv_outer, alphalevel, w0, w1
@@ -90,11 +104,10 @@
         def colmap1(dotvec): return (1,1,1)
 
         angles = 0
-        tex_scale = 1
-        tex_bias = 0
-        tex_format = [ 2, "HILO_NV", "HILO_NV" ]
+        tex = ( getIrreguTex(2, "HILO_NV", "HILO_NV"),
+                )
 
-    elif profile == "NV_COMB":
+    elif profile == "NV_COMB" or profile == "NV_COMB4":
         print "Using full displacement resolution textures with 
GL_NV_register_combiners"
 
         using_secondary_color = 1
@@ -129,18 +142,28 @@
         FCI G SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA
         """)
 
-        texenv_inner = texenv % "0 0 0 1"
-        texenv_outer = texenv % "%(dotvec)s 0"
-        
         alphalevel = 1
         w0,w1 = 1,1
         def colmap0(dotvec): return (1,1,1)
         def colmap1(dotvec): return (0,0,0)
 
-        angles = 3
-        tex_scale = 1
-        tex_bias = 0
-        tex_format = [ 4, "RGBA", "RGBA" ]
+        if profile == "NV_COMB":
+            texenv_inner = texenv % "0 0 0 1"
+            texenv_outer = texenv % "%(dotvec)s 0"
+            angles = 3
+            tex = ( getIrreguTex(4, "RGBA", "RGBA", angles = angles),
+                    getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 
1),
+                    )
+        else:
+            texenv_inner = texenv % "0 0 0 1"
+            texenv_outer = texenv % "%(dotvec)s"
+            angles = 4
+            tex = ( getIrreguTex(1, "INTENSITY", "LUMINANCE"),
+                    getIrreguTex(1, "INTENSITY", "LUMINANCE", invert = 1),
+                    getIrreguTex(4, "RGBA", "RGBA", angles = angles),
+                    getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 
1),
+                    )
+
 
     elif profile == "DOT3":
         print "Using 1/4 displacement resolution textures with 
GL_EXT_texture_env_dot3"
@@ -163,12 +186,12 @@
         def colmap1(dotvec): return [.5 + .25 * c for c in dotvec]
 
         angles = 3
-        tex_scale = .25
-        tex_bias = .75
-        tex_format = [ 4, "RGBA", "RGBA" ]
+        tex = ( getIrreguTex(4, "RGBA", "RGBA", scale = .25, bias = .75, 
angles = 3),
+                getIrreguTex(4, "RGBA", "RGBA", scale = .25, bias = .75, 
angles = 3, invert = 1),
+                )
 
     elif profile == "STD":
-        print "Using full displacement resolution texture with standard GL"
+        print "Using full displacement resolution texture with standard GL 
(texture_env_add)"
 
         texenv = """
         TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD
@@ -182,23 +205,14 @@
         def colmap1(dotvec): return (0,0,0,0)
         
         angles = 0
-        tex_scale = 1
-        tex_bias = 0
-        tex_format = [ 1, "INTENSITY", "LUMINANCE" ]
+        tex = ( getIrreguTex(1, "INTENSITY", "LUMINANCE"),
+                getIrreguTex(1, "INTENSITY", "LUMINANCE", invert = 1),
+                )
     else:
         assert(0)
 
 
-    args = ["radius", "2", "ripple_scale", str(ripple_scale),
-            "scale", str(tex_scale), "bias", str(tex_bias),
-            "angles", str(angles), "eps", ".125"]
-
-
-    tex = getCachedTexture([texsize, texsize, 0] + tex_format +
-                           ["irregu",  args], shade_all_levels = 1)
-    texinv = getCachedTexture([texsize, texsize, 0] + tex_format + 
-                              ["irregu", args + ["invert", "1"]],
-                              shade_all_levels = 1)
+    print "Using", angles, "precomputed slicing angles"
 
     global reinit
     reinit = 1
@@ -244,11 +258,15 @@
 
 def getIrregu(invert, x0, y0, x1, y1, outer = 0, texscale = 1, texangle = 0):
 
-    if invert and not using_shader:
-        texid = texinv.getTexId()
+    if len(tex) == 1:
+        texid = tex[0].getTexId()
+    elif len(tex) == 2:
+        texid = tex[invert].getTexId()
+    elif len(tex) == 4:
+        texid = tex[invert + 2 * outer].getTexId()
     else:
-        texid = tex.getTexId()
-
+        assert(0)
+    
     striplen = sqrt((x1 - x0)**2 + (y1 - y0)**2)
 
     m = 0.5 * ripple_scale * texscale / striplen
@@ -302,7 +320,7 @@
 
         dotvec = js(vec)
 
-    if not using_shader:
+    if not using_shader and angles < 4:
         # Interpolate outer edge towards inner edge with NV_COMB
         a = 2**-edgelodbias
         dotvec = js(vecmul(vec,a) + [1-a]) + " #"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]