/[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.43 by jvk, Sat Nov 2 12:29:55 2002 UTC revision 1.44 by jvk, Sat Nov 2 14:51:36 2002 UTC
# Line 37  if (GL.hasExtension("GL_NV_register_comb Line 37  if (GL.hasExtension("GL_NV_register_comb
37  if GL.hasExtension("GL_EXT_texture_env_dot3"):  if GL.hasExtension("GL_EXT_texture_env_dot3"):
38      profiles.append("DOT3")      profiles.append("DOT3")
39    
40  profiles.append("STD")  profiles.append("STD_MULTIPASS")
41    profiles.append("STD_CONSTD")
42  profiles.append("STD_4")  profiles.append("STD_4")
43    
44  def getIrreguTex(components, iformat, format, scale = 1, bias = 0, angle = 0, angles = 0, invert = 0):  def getIrreguTex(components, iformat, format, scale = 1, bias = 0, angle = 0, angles = 0, invert = 0):
# Line 73  def init(): Line 74  def init():
74      using_secondary_color = 0      using_secondary_color = 0
75      using_multitex = 0      using_multitex = 0
76    
77        print "Using profile:", profile
78    
79      if profile == "NV_PROG":      if profile == "NV_PROG":
80            print "Using 2-vector HILO displacement texture with GL_NV_fragment_program"
81          using_fragprog = 1          using_fragprog = 1
82                    
83          radius = 2          radius = 2
84          dh = [ sqrt(radius**2 - d**2) for d in range(0,radius+1) ]          dh = [ sqrt(radius**2 - d**2) for d in range(0,radius+1) ]
85    
86            global prog_inner, prog_outer
87            
88          prog_inner = GL.createProgram("""!!FP1.0          prog_inner = GL.createProgram("""!!FP1.0
89          # f[TEX0].xyw texture coordinates          # f[TEX0].xyw texture coordinates
90          # f[TEX2].xy texture HI and LO component weights          # f[TEX2].xy texture HI and LO component weights
# Line 376  def init(): Line 382  def init():
382                  getIrreguTex(4, "RGBA", "RGBA", scale = .25, bias = .75, angles = 3, invert = 1),                  getIrreguTex(4, "RGBA", "RGBA", scale = .25, bias = .75, angles = 3, invert = 1),
383                  )                  )
384    
385      elif profile == "STD" or profile == "STD_4":      elif profile == "STD_MULTIPASS" or profile == "STD_CONSTD" or profile == "STD_4":
386          print "Using full displacement resolution texture with standard GL (texture_env_add)"          print "Using full displacement resolution texture with standard GL (texture_env_add)"
387    
388          texenv = """          texenv = """
# Line 427  def globalkey(k): Line 433  def globalkey(k):
433          global scaling          global scaling
434          scaling = scalings[int(k) - 1]          scaling = scalings[int(k) - 1]
435          init()          init()
436      elif "F1" <= k <= "F12":      elif "F1" <= k <= "F9":
437          global profile          global profile
438          profile = profiles[int(k[1]) - 1]          profile = profiles[int(k[1]) - 1]
439          init()          init()
# Line 505  def getIrregu(invert, x0, y0, x1, y1, ou Line 511  def getIrregu(invert, x0, y0, x1, y1, ou
511      Enable TEXTURE_2D      Enable TEXTURE_2D
512      """ % locals()      """ % locals()
513    
514        # One-pixel difference of displacement
515        borderalpha = 1.0 / (scale * ripple_scale * texscale)
516    
517      if using_multitex and outer:      if using_multitex and outer:
518          # XXX: scaling doesn't work properly because the coordinate          # XXX: scaling doesn't work properly because the coordinate
519          #      transformation is not known here          #      transformation is not known here
# Line 513  def getIrregu(invert, x0, y0, x1, y1, ou Line 522  def getIrregu(invert, x0, y0, x1, y1, ou
522          # alpha: value added to the displacement values          # alpha: value added to the displacement values
523          # blue:  value added to the middle displacement (in addition to alpha)          # blue:  value added to the middle displacement (in addition to alpha)
524          m = 1.0 / (striplen * scale)          m = 1.0 / (striplen * scale)
525          alpha = 1.5 / (scale * ripple_scale * texscale)          alpha = 1.5 * borderalpha
526          blue = 1.0 / (scale * ripple_scale * texscale)          blue = 1.0 * borderalpha
527    
528          #print m*scale,alpha*256,blue*256          #print m*scale,alpha*256,blue*256
529                    
# Line 570  def getIrregu(invert, x0, y0, x1, y1, ou Line 579  def getIrregu(invert, x0, y0, x1, y1, ou
579          dx = cos(angle)          dx = cos(angle)
580          dy = sin(angle)          dy = sin(angle)
581    
         m = 1.0 / (striplen * scale)  
582          # Note: dx,dy below are applied after texture matrix          # Note: dx,dy below are applied after texture matrix
583          vec = (dx / scale,          vec = (dx / scale,
584                 dy / scale,                 dy / scale,
585                 0,                 0,
586                 1.0 / (scale * ripple_scale * texscale),                 borderalpha,
587                 )                 )
588    
589          texcoords += [ [ vec, vec, vec, vec, ],          texcoords += [ [ vec, vec, vec, vec, ],
# Line 627  def getIrregu(invert, x0, y0, x1, y1, ou Line 635  def getIrregu(invert, x0, y0, x1, y1, ou
635          ActiveTexture TEXTURE0          ActiveTexture TEXTURE0
636          """ % edgelodbias          """ % edgelodbias
637    
638    
639      if alphalevel:      if alphalevel:
640            da = (profile == "STD_CONSTD") * outer * borderalpha * 3
641            
642          code += """          code += """
643          Enable ALPHA_TEST          Enable ALPHA_TEST
644          AlphaFunc LESS %s          AlphaFunc LESS %s
645          """ % alphalevel          """ % (alphalevel - da)
646    
647      if outer:      if outer:
648          code += texenv_outer % locals()          code += texenv_outer % locals()
# Line 801  class IrreguScene: Line 812  class IrreguScene:
812          self.initIrregu()          self.initIrregu()
813    
814          if self.use_stencil:          if self.use_stencil:
815              if texenv_inner == texenv_outer and angles == 0:              if profile == "STD_MULTIPASS":
816                  vs.map.put(getDListNocoords("PushMatrix\n"                  vs.map.put(getDListNocoords("PushMatrix\n"
817                                              "Translate -2 0 0"))                                              "Translate -2 0 0"))
818                  vs.map.put(self.stencil_init)                  vs.map.put(self.stencil_init)

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

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