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 libtexture/irregu.texture


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture
Date: Mon, 21 Oct 2002 08:41:30 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/21 08:41:30

Modified files:
        gfx/demo       : irregu3.py 
        gfx/libtexture : irregu.texture 

Log message:
        Use stencil buffer

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irregu.texture.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.7 gzz/gfx/demo/irregu3.py:1.8
--- gzz/gfx/demo/irregu3.py:1.7 Mon Oct 21 03:07:15 2002
+++ gzz/gfx/demo/irregu3.py     Mon Oct 21 08:41:29 2002
@@ -6,8 +6,8 @@
 #                       "scale", "0.15", "freq", "1", "df", "2", 
 #                       "scale2", "0.25", "freq2", "10", "df2", ".5"])
 
-ripple_scale = 0.25
-tex.shade_all_levels(256, 256, 0, 4, "RGBA", "RGBA",
+ripple_scale = .25
+tex.shade_all_levels(128, 128, 0, 4, "RGBA", "RGBA",
                      "irregu", ["radius", "2", str(ripple_scale), "0.25",
                                 "scale", ".25", "bias", ".75", "eps", ".125"])
 
@@ -55,16 +55,16 @@
     TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
 
     # Debug strip
-    Begin QUAD_STRIP
-    TexCoord 0 0 0 1
-    Vertex 0 %(e)s 0 1
-    TexCoord 0 0 0 %(e)s
-    Vertex 0 %(e)s 0 %(e)s
-    TexCoord 1 0 0 1
-    Vertex 1 %(e)s 0 1
-    TexCoord %(e)s 0 0 %(e)s
-    Vertex %(e)s %(e)s 0 %(e)s
-    End
+    #Begin QUAD_STRIP
+    #TexCoord 0 0 0 1
+    #Vertex 0 %(e)s 0 1
+    #TexCoord 0 0 0 %(e)s
+    #Vertex 0 %(e)s 0 %(e)s
+    #TexCoord 1 0 0 1
+    #Vertex 1 %(e)s 0 1
+    #TexCoord %(e)s 0 0 %(e)s
+    #Vertex %(e)s %(e)s 0 %(e)s
+    #End
 
     BlendFunc ZERO ZERO
     Enable BLEND
@@ -111,7 +111,14 @@
 
     Disable BLEND
 
-    # Draw inner edge
+    # Create inner edge stencil
+
+    StencilMask 255
+    
+    Enable STENCIL_TEST
+    ColorMask 0 0 0 0
+    StencilFunc ALWAYS 0 255
+    StencilOp INCR INCR INCR
     
     TexEnv TEXTURE_ENV OPERAND0_RGB_ARB SRC_ALPHA
 
@@ -135,8 +142,25 @@
 
     End
 
-    PopMatrix
+    # Draw white using the stencil
+
+    StencilFunc LESS 0 255
+    StencilOp ZERO ZERO ZERO
+    ColorMask 1 1 1 1
+
+    Disable TEXTURE_2D
+    Color 1 1 1 1
+
+    Begin QUAD_STRIP
+    Vertex 0 .5 
+    Vertex 0 1
+    Vertex 1 .5
+    Vertex 1 1
+    End 
+
+    Disable STENCIL_TEST
     
+    PopMatrix
 
     PopAttrib 
 """ % vars())
@@ -149,18 +173,18 @@
 
 class IrreguScene:
     def __init__(self):
-        self.scale = 8
+        self.scale = 128
         
     def scene(self, vs):
-        putnoc(vs, background((0.1,0.4,0.5)))
+        putnoc(vs, background((0.7,0.7,1.0)))
 
-        cs1 = vs.coords.affineCoordsys(0, 0, 512, 384, 128*self.scale, 0, 0, 
-64*self.scale)
+        cs1 = vs.coords.affineCoordsys(0, 0, 512, 384, self.scale, 0, 0, 
-2*ripple_scale*self.scale)
        vs.matcher.add(cs1, "1")
 
         vs.map.put(irr, cs1)
 
     def key(self, k):
-        if k == "+": self.scale *= 2.0
-        if k == "-": self.scale /= 2.0
+        if k == "+": self.scale *= 1.4142135623731; print round(self.scale)
+        if k == "-": self.scale /= 1.4142135623731; print round(self.scale)
 
 currentScene = IrreguScene()        
Index: gzz/gfx/libtexture/irregu.texture
diff -u gzz/gfx/libtexture/irregu.texture:1.3 
gzz/gfx/libtexture/irregu.texture:1.4
--- gzz/gfx/libtexture/irregu.texture:1.3       Mon Oct 21 03:33:48 2002
+++ gzz/gfx/libtexture/irregu.texture   Mon Oct 21 08:41:30 2002
@@ -6,7 +6,7 @@
 float func(float x, float y) {
     float t = x*10;
     float u = y*10;
-    return .5 + .3 * sin(x*M_PI*2*4) - .2*(t-floor(t)) + .2*sin(y*M_PI*2)
+    return .5 + .2 * sin(x*M_PI*2*4) - .2*(t-floor(t)) + .2*sin(y*M_PI*2)
        +  .2*(u-floor(u));
 }
 




reply via email to

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