[Top][All Lists]
[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: |
Tue, 29 Oct 2002 08:24:14 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/10/29 08:24:14
Modified files:
gfx/demo : irregu3.py
gfx/libtexture : irregu.texture
Log message:
Add standard GL precomputed slicing angle profile
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irregu.texture.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.29 gzz/gfx/demo/irregu3.py:1.30
--- gzz/gfx/demo/irregu3.py:1.29 Tue Oct 29 07:32:59 2002
+++ gzz/gfx/demo/irregu3.py Tue Oct 29 08:24:14 2002
@@ -22,21 +22,23 @@
if (GL.hasExtension("GL_NV_register_combiners") and
GL.hasExtension("GL_EXT_secondary_color")):
- profiles.append("NV_COMB")
- profiles.append("NV_COMB4")
+ profiles.append("NV_COMB_DOT3")
+ profiles.append("NV_COMB_DOT4")
if GL.hasExtension("GL_EXT_texture_env_dot3"):
profiles.append("DOT3")
profiles.append("STD")
+profiles.append("STD_4")
-def getIrreguTex(components, iformat, format, scale = 1, bias = 0, angles = 0,
invert = 0):
+def getIrreguTex(components, iformat, format, scale = 1, bias = 0, angle = 0,
angles = 0, invert = 0):
return getCachedTexture([texsize, texsize, 0, components, iformat, format,
"irregu",
["radius", "2",
"ripple_scale", str(ripple_scale),
"scale", str(scale),
"bias", str(bias),
+ "angle", str(angle),
"angles", str(angles),
"eps", ".125",
"invert", str(invert),
@@ -44,7 +46,7 @@
shade_all_levels = 1)
def init(profile):
- global tex, texinv
+ global tex
global texenv_inner, texenv_outer, alphalevel, w0, w1
global colmap0, colmap1, angles
global using_shader, using_secondary_color
@@ -107,7 +109,7 @@
tex = ( getIrreguTex(2, "HILO_NV", "HILO_NV"),
)
- elif profile == "NV_COMB" or profile == "NV_COMB4":
+ elif profile == "NV_COMB_DOT3" or profile == "NV_COMB_DOT4":
print "Using full displacement resolution textures with
GL_NV_register_combiners"
using_secondary_color = 1
@@ -147,7 +149,7 @@
def colmap0(dotvec): return (1,1,1)
def colmap1(dotvec): return (0,0,0)
- if profile == "NV_COMB":
+ if profile == "NV_COMB_DOT3":
texenv_inner = texenv % "0 0 0 1"
texenv_outer = texenv % "%(dotvec)s 0"
angles = 3
@@ -190,7 +192,7 @@
getIrreguTex(4, "RGBA", "RGBA", scale = .25, bias = .75,
angles = 3, invert = 1),
)
- elif profile == "STD":
+ elif profile == "STD" or profile == "STD_4":
print "Using full displacement resolution texture with standard GL
(texture_env_add)"
texenv = """
@@ -203,11 +205,20 @@
w0,w1 = 1,1
def colmap0(dotvec): return (1,1,1,1)
def colmap1(dotvec): return (0,0,0,0)
-
- angles = 0
+
+ angles = 0
tex = ( getIrreguTex(1, "INTENSITY", "LUMINANCE"),
getIrreguTex(1, "INTENSITY", "LUMINANCE", invert = 1),
)
+
+ if profile == "STD_4":
+ texenv_outer = texenv_outer + "\n"
+ angles = 4
+ for i in range(0, angles):
+ angle = i * 180. / angles
+ tex += ( getIrreguTex(1, "INTENSITY", "LUMINANCE", angle =
angle, angles = 1),
+ getIrreguTex(1, "INTENSITY", "LUMINANCE", angle =
angle, angles = 1, invert = 1) )
+
else:
assert(0)
@@ -218,13 +229,17 @@
reinit = 1
+print "Profiles:"
+for i in range(0, len(profiles)):
+ print ("F%s:" % (i+1)), profiles[i]
+
init(profiles[0])
def globalkey(k):
global reinit
- if "F1" <= k <= "F4":
+ if "F1" <= k <= "F8":
global profiles
init(profiles[int(k[1]) - 1])
elif k == "m":
@@ -257,15 +272,6 @@
def vecsub(u, v): return [ u[i] - v[i] for i in range(0, len(u)) ]
def getIrregu(invert, x0, y0, x1, y1, outer = 0, texscale = 1, texangle = 0):
-
- if len(tex) == 1:
- texid = tex[0].getTexId()
- elif len(tex) == 2:
- texid = tex[invert].getTexId()
- elif len(tex) == 4:
- texid = tex[invert + 2 * outer].getTexId()
- else:
- assert(0)
striplen = sqrt((x1 - x0)**2 + (y1 - y0)**2)
@@ -286,6 +292,20 @@
]
angle = atan2(y1 - y0, x1 - x0) - texangle
+
+ if len(tex) == 1:
+ texid = tex[0].getTexId()
+ elif len(tex) == 2:
+ texid = tex[invert].getTexId()
+ elif len(tex) == 4:
+ texid = tex[invert + 2 * outer].getTexId()
+ elif len(tex) == 2 * (1 + angles):
+ a = angle * (angles / pi)
+ while a < 0: a += angles
+ i0 = int(a + .5) % angles
+ texid = tex[ 2 * outer * (i0 + 1) + invert ].getTexId()
+ else:
+ assert(0)
if using_shader:
dx = -cos(angle)
Index: gzz/gfx/libtexture/irregu.texture
diff -u gzz/gfx/libtexture/irregu.texture:1.13
gzz/gfx/libtexture/irregu.texture:1.14
--- gzz/gfx/libtexture/irregu.texture:1.13 Tue Oct 29 06:53:53 2002
+++ gzz/gfx/libtexture/irregu.texture Tue Oct 29 08:24:14 2002
@@ -30,6 +30,7 @@
FPARAM(eps, .25);
FPARAM(invert, 0);
FPARAM(quantize, 255);
+ FPARAM(angle, 0);
int angles = (int)params->getFloat("angles", 0);
// Note: radius is specified in texels
@@ -94,8 +95,8 @@
for (int comp = 0; comp < angles && comp < components; comp++) {
- float dx = cos(comp * M_PI / angles);
- float dy = sin(comp * M_PI / angles);
+ float dx = cos(comp * M_PI / angles + angle * (M_PI / 180));
+ float dy = sin(comp * M_PI / angles + angle * (M_PI / 180));
ind = 0;
for (j = 0, y = 0; j < height; j++, y += ystep) {
@@ -105,7 +106,7 @@
float maxh = -1E+10;
for (float r = -radius; r <= radius; r += eps) {
- float h = filter(data + 3, width, height, components,
+ float h = filter(data + 3, width, height, 4,
i + dx * r, j + dy * r);
h += sqrt(radius * radius - r * r) * m;
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/22
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/25
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/25
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/28
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/29
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture,
Janne V. Kujala <=