4 |
import gzz |
import gzz |
5 |
import java |
import java |
6 |
import math |
import math |
7 |
from gfx.libutil.nvcode import combinercode |
from gfx.libutil.nvcode import parseCombiner |
8 |
from gfx.libpaper.texcache import getCachedTexture |
from gfx.libpaper.texcache import getCachedTexture |
9 |
|
|
10 |
class IrreguFrame(IrregularFrame): |
class IrreguFrame(IrregularFrame): |
11 |
dicefactor = 0.8 |
dicefactor = 0.8 |
12 |
|
|
13 |
tex = GL.createTexture() |
tex = GL.createTexture() |
14 |
tex.shade(128, 128, 0, 4, "RGBA", "RGBA", |
tex.shade(128, 128, 0, 1, "INTENSITY", "LUMINANCE", |
15 |
"sawnoise", ["bias", "0.5", |
"sawnoise", ["bias", "0.5", |
16 |
"scale", "0.15", "freq", "1", "df", "2", |
"scale", "0.15", "freq", "1", "df", "2", |
17 |
"scale2", "0.25", "freq2", "10", "df2", ".5"]) |
"scale2", "0.25", "freq2", "10", "df2", ".5"]) |
86 |
"color" : gzz.util.ColorUtil.colorGLString(color)} |
"color" : gzz.util.ColorUtil.colorGLString(color)} |
87 |
|
|
88 |
def code2(color): |
def code2(color): |
89 |
return combinercode(""" |
return parseCombiner(""" |
90 |
PushAttrib ENABLE_BIT TEXTURE_BIT |
PushAttrib ENABLE_BIT TEXTURE_BIT |
|
|
|
91 |
CombinerParameterNV CONSTANT_COLOR0_NV %(color)s 1 |
CombinerParameterNV CONSTANT_COLOR0_NV %(color)s 1 |
92 |
|
|
93 |
Enable REGISTER_COMBINERS_NV |
Enable REGISTER_COMBINERS_NV |
|
CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2 |
|
94 |
|
|
95 |
# SPARE0 <- TEXTURE0 . COLOR |
SPARE0 = TEX0 . COL0 |
96 |
CI0 RGB A TEXTURE0 UNSIGNED_IDENTITY_NV RGB |
SPARE0.alpha = TEX0.alpha * COL0.alpha + COL1.blue |
97 |
CI0 RGB B PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB |
|
98 |
CO0 RGB SPARE0_NV DISCARD_NV DISCARD_NV NONE NONE TRUE FALSE FALSE |
SPARE0.alpha = SPARE0.blue + SPARE0.alpha |
99 |
|
|
100 |
# SPARE0.alpha <- TEXTURE0.alpha * COLOR.alpha + SEC_COLOR.b |
alpha = SPARE0.alpha |
101 |
CI0 ALPHA A TEXTURE0 UNSIGNED_IDENTITY_NV ALPHA |
color = CONST0 |
|
CI0 ALPHA B PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV ALPHA |
|
|
CI0 ALPHA C SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE |
|
|
CI0 ALPHA D ZERO UNSIGNED_INVERT_NV ALPHA |
|
|
CO0 ALPHA DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE FALSE |
|
|
|
|
|
# SPARE0.alpha <- SPARE0 + SPARE0.alpha |
|
|
CI1 ALPHA A SPARE0_NV UNSIGNED_IDENTITY_NV BLUE |
|
|
CI1 ALPHA B ZERO UNSIGNED_INVERT_NV ALPHA |
|
|
CI1 ALPHA C SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA |
|
|
CI1 ALPHA D ZERO UNSIGNED_INVERT_NV ALPHA |
|
|
CO1 ALPHA DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE FALSE |
|
|
|
|
|
# color <- CONTANT_COLOR0 |
|
|
# alpha <- SPARE0.alpha |
|
|
FCI A ZERO UNSIGNED_IDENTITY_NV RGB |
|
|
FCI B ZERO UNSIGNED_IDENTITY_NV RGB |
|
|
FCI C ZERO UNSIGNED_IDENTITY_NV RGB |
|
|
FCI D CONSTANT_COLOR0_NV UNSIGNED_IDENTITY_NV RGB |
|
|
FCI G SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA |
|
102 |
|
|
103 |
BindTexture TEXTURE_2D %(tex)s |
BindTexture TEXTURE_2D %(tex)s |
104 |
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR |
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR |
107 |
|
|
108 |
Enable ALPHA_TEST |
Enable ALPHA_TEST |
109 |
AlphaFunc GEQUAL 1.0 |
AlphaFunc GEQUAL 1.0 |
110 |
|
|
111 |
|
Color 0 0 0 1 |
112 |
""") % {"tex" : self.tex2.getTexId(), |
""") % {"tex" : self.tex2.getTexId(), |
113 |
"color" : gzz.util.ColorUtil.colorGLString(color)} |
"color" : gzz.util.ColorUtil.colorGLString(color)} |
114 |
|
|
127 |
if ratio < 3./4 or ratio > 4./3: |
if ratio < 3./4 or ratio > 4./3: |
128 |
print "WARNING: anisotropy ratio", round(ratio,2), "is far from one" |
print "WARNING: anisotropy ratio", round(ratio,2), "is far from one" |
129 |
|
|
130 |
self._content = GLRen.createIrregularEllipse( |
# Irregu flags |
131 |
texscale, ripple_scale, 0, code2(contentColor), 1) |
Y_COLOR = 1; |
132 |
self._frame = GLRen.createIrregularEllipse( |
Y_SECCOLOR = 2; |
133 |
texscale, ripple_scale, 1, code2(frameColor), 1) |
DOTVEC_COLOR = 4; |
134 |
|
INTERP_DOTVEC = 8; |
135 |
|
SLICE_1D = 16; |
136 |
|
SLICE_2D = 32; |
137 |
|
SHIFTS = 64; |
138 |
|
INSIDE = 128; |
139 |
|
SHIFTS8 = 256; |
140 |
|
|
141 |
|
self._content = GLRen.createIrregularEdge( |
142 |
|
0, texscale, 2.0, 128, 0, |
143 |
|
-.5 * ripple_scale * texscale, |
144 |
|
.5 * ripple_scale * texscale, |
145 |
|
0, "1 1 1 1 0 0 0 0", "", 3, 0, |
146 |
|
SLICE_1D + Y_SECCOLOR + INSIDE, |
147 |
|
code2(contentColor), |
148 |
|
1.0) |
149 |
|
|
150 |
|
self._frame = GLRen.createIrregularEdge( |
151 |
|
0, texscale, 2.0, 128, 0, |
152 |
|
-.5 * ripple_scale * texscale, |
153 |
|
.5 * ripple_scale * texscale, |
154 |
|
0, "1 1 1 1 0 0 0 0", "", 3, 0, |
155 |
|
SLICE_1D + Y_SECCOLOR + DOTVEC_COLOR + INTERP_DOTVEC, |
156 |
|
code2(frameColor), |
157 |
|
1.0) |
158 |
|
|
159 |
def getContent(self): return self._content |
def getContent(self): return self._content |
160 |
def getFrame(self): return self._frame |
def getFrame(self): return self._frame |