/[fenfire]/fenfire/org/fenfire/spanimages/gl/papermakers.py
ViewVC logotype

Diff of /fenfire/org/fenfire/spanimages/gl/papermakers.py

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

revision 1.3 by tjl, Wed Jun 25 10:35:37 2003 UTC revision 1.4 by tjl, Thu Jun 26 08:53:54 2003 UTC
# Line 2  Line 2 
2    
3  # PaperMaker implementations  # PaperMaker implementations
4    
5    from __future__ import nested_scopes;
6    
7  from org.nongnu.libvob.gl import GL, PaperMill  from org.nongnu.libvob.gl import GL, PaperMill
8  from vob.putil.nvcode import parseCombiner  from vob.putil.nvcode import parseCombiner
9    
10  from org.fenfire.spanimages.gl import PlainPaperMaker  from org.fenfire.spanimages.gl import PlainPaperMaker
11    
12  anisofilter = """  anisofilter = """
13     TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_NEAREST     TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
14     TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR     TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
15     TexParameter TEXTURE_2D TEXTURE_MAX_ANISOTROPY_EXT 10  #   TexParameter TEXTURE_2D TEXTURE_MAX_ANISOTROPY_EXT 10
16  """  """
17    
18  def white(w = None, paperMill = None, filter = anisofilter):  def white(w = None, paperMill = None, filter = anisofilter):
19      return PlainPaperMaker(1, """      return PlainPaperMaker(1, """
         PushAttrib TEXTURE_BIT  
20          TexEnv TEXTURE_ENV TEXTURE_ENV_MODE REPLACE          TexEnv TEXTURE_ENV TEXTURE_ENV_MODE REPLACE
21         Enable TEXTURE_2D         Enable TEXTURE_2D
22          Disable BLEND          Disable BLEND
23      """ + filter, """      """ + filter, """
         PopAttrib  
24      """, None)      """, None)
25    
26  def fancyBlend(w, paperMill = None, filter = anisofilter):  def fancyBlend(w, paperMill = None, filter = anisofilter):
# Line 39  def fancyBlend(w, paperMill = None, filt Line 39  def fancyBlend(w, paperMill = None, filt
39              ActiveTexture TEXTURE0              ActiveTexture TEXTURE0
40          """ % filter, "", None, paperMill, w)          """ % filter, "", None, paperMill, w)
41    
42    class HaloPaperMaker_2tex(PlainPaperMaker):
43        def __init__(self, paperMill, w):
44            PlainPaperMaker.__init__(self, 1,
45                 parseCombiner("""
46                    ActiveTexture TEXTURE0
47                    Enable TEXTURE_2D
48                    %(filter)s
49                    Disable BLEND
50                    ActiveTexture TEXTURE1
51                    Enable TEXTURE_2D
52                    %(filter)s
53                    TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 3
54                    ActiveTexture TEXTURE0
55    
56                    Enable REGISTER_COMBINERS_NV
57                    CONST0 = 0 0 0 .5
58                    CONST1 = 0 0 0 .15
59    
60                    # Get luminance multiplied by 12 * CONST1.a
61                    SPARE0 = ((1-TEX1) . (CONST1.a))*4
62    
63                    # Multiply by another 3
64                    SPARE0 = (SPARE0 . (1))*1
65    
66                    # Limit maximum effect
67                    EF = SPARE0 * CONST0.a
68    
69                    # Blend the halo over the texture
70                    color = EF * (1) + (1 - EF) * TEX0
71                    alpha = 1
72                """ % { "filter" : anisofilter }),
73                """
74                """,
75                None, paperMill, w)
76        def makePaper(self, img, texgen):
77            p = PlainPaperMaker.makePaper(self, img, texgen)
78            #print p.getPass(0).getSetupcode()
79            p.setNPasses(2)
80            pas = p.getPass(1)
81            pas.setNTexGens(1)
82            pas.putNormalTexGen(0, texgen)
83            pas.setSetupcode("""
84                ActiveTexture TEXTURE0
85                Enable TEXTURE_2D
86                Enable BLEND
87                BlendFunc ZERO SRC_COLOR
88                BindTexture TEXTURE_2D %s
89                TexEnv TEXTURE_ENV TEXTURE_ENV_MODE REPLACE
90            """ % img.loader.getTexture().getTexId())
91            pas.setTeardowncode("""
92            """)
93            return p
94    
95    
96  def fancyHalo(w, paperMill = None):  def fancyHalo(w, paperMill = None):
97      if not GL.hasExtension("GL_NV_register_combiners"):      if not GL.hasExtension("GL_NV_register_combiners"):
98          print "fancy Halo for text not possible without GL_NV_register_combiners"          print "fancy Halo for text not possible without GL_NV_register_combiners"
# Line 46  def fancyHalo(w, paperMill = None): Line 100  def fancyHalo(w, paperMill = None):
100          return fancyBlend(w, paperMill)          return fancyBlend(w, paperMill)
101      if paperMill == None:      if paperMill == None:
102          paperMill = PaperMill.getInstance()          paperMill = PaperMill.getInstance()
103      return PlainPaperMaker(1,      return HaloPaperMaker_2tex(paperMill, w)
          parseCombiner("""  
             PushAttrib ENABLE_BIT TEXTURE_BIT COLOR_BUFFER_BIT CURRENT_BIT  
             ActiveTexture TEXTURE0  
             Enable TEXTURE_2D  
             Disable BLEND  
             ActiveTexture TEXTURE1  
             TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 3  
             ActiveTexture TEXTURE0  
   
             Enable REGISTER_COMBINERS_NV  
             CONST0 = 0 0 0 .5  
             CONST1 = 0 0 0 .15  
   
             # Get luminance multiplied by 12 * CONST1.a  
             SPARE0 = ((1-TEX1) . (CONST1.a))*4  
   
             # Multiply by another 3  
             SPARE0 = (SPARE0 . (1))*1  
   
             # Limit maximum effect  
             EF = SPARE0 * CONST0.a  
   
             # Blend the halo over the texture  
             color = EF * (1) + (1 - EF) * TEX0  
             alpha = 1  
         """),  
         """  
             PopAttrib  
         """,  
         None, paperMill, w)  
104    
105  blurProgram = None  blurProgram = None
106    
# Line 115  def fancyBlur(w, paperMill = None): Line 139  def fancyBlur(w, paperMill = None):
139      if not blurProgram:      if not blurProgram:
140          print "Fancy blurring is not possible without GL_ARB_fragment_program."          print "Fancy blurring is not possible without GL_ARB_fragment_program."
141          print "Punting to Fancy halo"          print "Punting to Fancy halo"
142            return fancyHalo(w, paperMill)
143    
144      if paperMill == None:      if paperMill == None:
145          paperMill = PaperMill.getInstance()          paperMill = PaperMill.getInstance()
146    
147      return PlainPaperMaker(1, """      return PlainPaperMaker(1, """
         PushAttrib ENABLE_BIT TEXTURE_BIT COLOR_BUFFER_BIT CURRENT_BIT  
148          BindProgram FRAGMENT_PROGRAM_ARB %s          BindProgram FRAGMENT_PROGRAM_ARB %s
149          Enable FRAGMENT_PROGRAM_ARB          Enable FRAGMENT_PROGRAM_ARB
150          Disable REGISTER_COMBINERS_NV          Disable REGISTER_COMBINERS_NV
151          Disable BLEND          Disable BLEND
152      """ % blurProgram.getProgId(),      """ % blurProgram.getProgId(),
153      """      """
         PopAttrib  
154      """, [blurProgram], paperMill, w)      """, [blurProgram], paperMill, w)
155    
156    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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