/[gzz]/gzz/gfx/demo/irregu3.py
ViewVC logotype

Diff of /gzz/gfx/demo/irregu3.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by jvk, Tue Oct 29 13:24:14 2002 UTC revision 1.31 by jvk, Tue Oct 29 16:11:03 2002 UTC
# Line 22  if (GL.hasExtension("GL_NV_texture_shade Line 22  if (GL.hasExtension("GL_NV_texture_shade
22    
23  if (GL.hasExtension("GL_NV_register_combiners") and  if (GL.hasExtension("GL_NV_register_combiners") and
24      GL.hasExtension("GL_EXT_secondary_color")):      GL.hasExtension("GL_EXT_secondary_color")):
25        if (GL.getGLFloat("MAX_GENERAL_COMBINERS_NV") >= 4 and
26            GL.getGLFloat("MAX_TEXTURE_UNITS") >= 3):
27            profiles.append("NV_COMB_MULTITEX")
28        
29      profiles.append("NV_COMB_DOT3")      profiles.append("NV_COMB_DOT3")
30      profiles.append("NV_COMB_DOT4")      profiles.append("NV_COMB_DOT4")
31    
# Line 49  def init(profile): Line 53  def init(profile):
53      global tex      global tex
54      global texenv_inner, texenv_outer, alphalevel, w0, w1      global texenv_inner, texenv_outer, alphalevel, w0, w1
55      global colmap0, colmap1, angles      global colmap0, colmap1, angles
56      global using_shader, using_secondary_color      global using_shader, using_secondary_color, using_multitex
57    
58      using_shader = 0      using_shader = 0
59      using_secondary_color = 0      using_secondary_color = 0
60        using_multitex = 0
61            
62      if profile == "NV_SHAD":      if profile == "NV_SHAD":
63          print "Using 2-vector HILO displacement texture with GL_NV_texture_shader"          print "Using 2-vector HILO displacement texture with GL_NV_texture_shader"
# Line 109  def init(profile): Line 114  def init(profile):
114          tex = ( getIrreguTex(2, "HILO_NV", "HILO_NV"),          tex = ( getIrreguTex(2, "HILO_NV", "HILO_NV"),
115                  )                  )
116    
117      elif profile == "NV_COMB_DOT3" or profile == "NV_COMB_DOT4":      elif profile == "NV_COMB_MULTITEX":
118    
119            alphalevel = 1
120            w0,w1 = 1,1
121            def colmap0(dotvec): return (1,1,1)
122            def colmap1(dotvec): return (1,1,1)
123    
124            tex = ( getIrreguTex(1, "INTENSITY", "LUMINANCE"),
125                    )
126    
127        elif profile == "NV_COMB_DOT3" or profile == "NV_COMB_DOT4" or profile == "NV_COMB_MULTITEX":
128          print "Using full displacement resolution textures with GL_NV_register_combiners"          print "Using full displacement resolution textures with GL_NV_register_combiners"
129    
130          using_secondary_color = 1          using_secondary_color = 1
# Line 156  def init(profile): Line 171  def init(profile):
171              tex = ( getIrreguTex(4, "RGBA", "RGBA", angles = angles),              tex = ( getIrreguTex(4, "RGBA", "RGBA", angles = angles),
172                      getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 1),                      getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 1),
173                      )                      )
174          else:          elif profile == "NV_COMB_DOT4":
175              texenv_inner = texenv % "0 0 0 1"              texenv_inner = texenv % "0 0 0 1"
176              texenv_outer = texenv % "%(dotvec)s"              texenv_outer = texenv % "%(dotvec)s"
177              angles = 4              angles = 4
# Line 165  def init(profile): Line 180  def init(profile):
180                      getIrreguTex(4, "RGBA", "RGBA", angles = angles),                      getIrreguTex(4, "RGBA", "RGBA", angles = angles),
181                      getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 1),                      getIrreguTex(4, "RGBA", "RGBA", angles = angles, invert = 1),
182                      )                      )
183            else:
184                using_multitex = 1
185                texenv_inner = texenv % "0 0 0 1"
186                texenv_outer = combinercode("""
187            # compute alpha = max( SEC_COL.b + TEX0 + COL.alpha + COL.b,
188            #                      SEC_COL.b + TEX1 + COL.alpha,
189            #                      SEC_COL.b + TEX2 + COL.alpha )
190            
191            Enable REGISTER_COMBINERS_NV
192            CombinerParameterNV NUM_GENERAL_COMBINERS_NV 4
193    
194            # TEX2 -= TEX1
195            CI0 RGB A TEXTURE2 UNSIGNED_IDENTIY_NV RGB
196            CI0 RGB B ZERO_NV UNSIGNED_INVERT_NV RGB
197            CI0 RGB C TEXTURE1 SIGNED_NEGATE_NV RGB
198            CI0 RGB D ZERO_NV UNSIGNED_INVERT_NV RGB
199            CO0 RGB DISCARD_NV DISCARD_NV TEXTURE2_NV NONE NONE FALSE FALSE FALSE
200    
201            # TEX0 += COL.b
202            CI0 ALPHA A TEXTURE0 UNSIGNED_IDENTIY_NV ALPHA
203            CI0 ALPHA B ZERO_NV UNSIGNED_INVERT_NV ALPHA
204            CI0 ALPHA C PRIMARY_COLOR_NV UNSIGEND_IDENTITY_NV BLUE
205            CI0 ALPHA D ZERO_NV UNSIGNED_INVERT_NV ALPHA
206            CO0 ALPHA DISCARD_NV DISCARD_NV TEXTURE0_NV NONE NONE FALSE FALSE FALSE
207    
208    
209            # TEX1 -= TEX0
210            CI1 RGB A TEXTURE1 UNSIGNED_IDENTIY_NV RGB
211            CI1 RGB B ZERO_NV UNSIGNED_INVERT_NV RGB
212            CI1 RGB C TEXTURE0 SIGNED_NEGATE_NV ALPHA
213            CI1 RGB D ZERO_NV UNSIGNED_INVERT_NV RGB
214            CO1 RGB DISCARD_NV DISCARD_NV TEXTURE1_NV NONE NONE FALSE FALSE FALSE
215    
216            # TEX0 += COL.alpha
217            CI1 ALPHA A TEXTURE0 UNSIGNED_IDENTIY_NV ALPHA
218            CI1 ALPHA B ZERO_NV UNSIGNED_INVERT_NV ALPHA
219            CI1 ALPHA C PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV ALPHA
220            CI1 ALPHA D ZERO_NV UNSIGNED_INVERT_NV ALPHA
221            CO1 ALPHA DISCARD_NV DISCARD_NV TEXTURE0_NV NONE NONE FALSE FALSE FALSE
222    
223    
224            # TEX1 += unsigned(TEX2)
225            CI2 RGB A TEXTURE1 SIGNED_IDENTIY_NV RGB
226            CI2 RGB B ZERO_NV UNSIGNED_INVERT_NV RGB
227            CI2 RGB C TEXTURE2 UNSIGNED_IDENTITY_NV RGB
228            CI2 RGB D ZERO_NV UNSIGNED_INVERT_NV RGB
229            CO2 RGB DISCARD_NV DISCARD_NV TEXTURE1_NV NONE NONE FALSE FALSE FALSE
230    
231            # TEX0 += SEC_COL.b
232            CI2 ALPHA A TEXTURE0 UNSIGNED_IDENTIY_NV ALPHA
233            CI2 ALPHA B ZERO_NV UNSIGNED_INVERT_NV ALPHA
234            CI2 ALPHA C SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE
235            CI2 ALPHA D ZERO_NV UNSIGNED_INVERT_NV ALPHA
236            CO2 ALPHA DISCARD_NV DISCARD_NV TEXTURE0_NV NONE NONE FALSE FALSE FALSE
237    
238    
239            # TEX0 += unsigned(TEX1)
240            CI3 RGB A TEXTURE0 SIGNED_IDENTIY_NV ALPHA
241            CI3 RGB B ZERO_NV UNSIGNED_INVERT_NV RGB
242            CI3 RGB C TEXTURE1 UNSIGNED_IDENTITY_NV RGB
243            CI3 RGB D ZERO_NV UNSIGNED_INVERT_NV RGB
244            CO3 RGB DISCARD_NV DISCARD_NV TEXTURE0_NV NONE NONE FALSE FALSE FALSE
245    
246    
247            # alpha <- TEXTURE0
248            FCI G TEXTURE0_NV UNSIGNED_IDENTITY_NV BLUE
249            """)
250                angles = 0
251                tex = ( getIrreguTex(1, "INTENSITY", "LUMINANCE"),
252                        getIrreguTex(1, "INTENSITY", "LUMINANCE", invert = 1),
253                        )
254                
255    
256    
257    
258    
259      elif profile == "DOT3":      elif profile == "DOT3":
# Line 212  def init(profile): Line 301  def init(profile):
301                  )                  )
302    
303          if profile == "STD_4":          if profile == "STD_4":
             texenv_outer = texenv_outer + "\n"  
304              angles = 4              angles = 4
305              for i in range(0, angles):              for i in range(0, angles):
306                  angle = i * 180. / angles                  angle = i * 180. / angles
# Line 323  def getIrregu(invert, x0, y0, x1, y1, ou Line 411  def getIrregu(invert, x0, y0, x1, y1, ou
411                           ]                           ]
412                         ]                         ]
413    
414        if using_multitex and outer:
415            t = .01
416            dx = cos(angle) * t
417            dy = sin(angle) * t
418            
419            texcoords += [ [ vecmul((x0+dx,y0+dy,0,texscale), w0),
420                             vecmul((x0+dx,y0+dy,0,texscale), w1),
421                             vecmul((x1+dx,y1+dy,0,texscale), w0),
422                             vecmul((x1+dx,y1+dy,0,texscale), w1)
423                             ],
424                           [ vecmul((x0-dx,y0-dy,0,texscale), w0),
425                             vecmul((x0-dx,y0-dy,0,texscale), w1),
426                             vecmul((x1-dx,y1-dy,0,texscale), w0),
427                             vecmul((x1-dx,y1-dy,0,texscale), w1)
428                             ]
429                           ]
430    
431      vec = [ 0 for i in range(0, angles) ]      vec = [ 0 for i in range(0, angles) ]
432    
433      if angles:      if angles:
# Line 360  def getIrregu(invert, x0, y0, x1, y1, ou Line 465  def getIrregu(invert, x0, y0, x1, y1, ou
465      TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR      TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
466      Enable TEXTURE_2D      Enable TEXTURE_2D
467      """ % locals()      """ % locals()
468    
469        if using_multitex:
470            code += """
471            ActiveTexture TEXTURE1
472            BindTexture TEXTURE_2D %(texid)s
473            TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
474            TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
475            Enable TEXTURE_2D
476            ActiveTexture TEXTURE2
477            BindTexture TEXTURE_2D %(texid)s
478            TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
479            TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
480            Enable TEXTURE_2D
481            ActiveTexture TEXTURE0
482            """
483            
484      if GL.hasExtension("GL_EXT_texture_lod_bias"):      if GL.hasExtension("GL_EXT_texture_lod_bias"):
485          code += """          code += """
# Line 529  class IrreguScene: Line 649  class IrreguScene:
649          self.initIrregu()          self.initIrregu()
650    
651          if self.use_stencil:          if self.use_stencil:
652              if texenv_inner == texenv_outer:              if texenv_inner == texenv_outer and angles == 0:
653                  vs.map.put(getDListNocoords("PushMatrix\n"                  vs.map.put(getDListNocoords("PushMatrix\n"
654                                              "Translate -2 0 0"))                                              "Translate -2 0 0"))
655                  vs.map.put(self.stencil_init)                  vs.map.put(self.stencil_init)

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26