[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/texlab.py libpaper/papermill.py li...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/texlab.py libpaper/papermill.py li... |
Date: |
Wed, 09 Oct 2002 10:07:27 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/10/09 10:07:27
Modified files:
gfx/demo : texlab.py
gfx/libpaper : papermill.py texcomb_NV1X.py texops_STD.py
textures.py
gfx/libtexture : geometric.texture
gfx/libutil : nvcode.py
Log message:
libpaper enhancements: new textures; combiner scale controlling
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/texlab.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texcomb_NV1X.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texops_STD.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/textures.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/geometric.texture.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/nvcode.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/texlab.py
diff -c gzz/gfx/demo/texlab.py:1.5 gzz/gfx/demo/texlab.py:1.6
*** gzz/gfx/demo/texlab.py:1.5 Tue Oct 8 12:09:54 2002
--- gzz/gfx/demo/texlab.py Wed Oct 9 10:07:27 2002
***************
*** 11,31 ****
tres = 128
args = [
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
! "seed", "1412"]],
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["turb", "1", "scale", ".3", "freq", "1",
! "freq2", "100", "df", "2", "bias", "0"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "0"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "1"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "2"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "3"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "5"]],
! ]
from gfx.libpaper.textures import getCachedTexture
--- 11,35 ----
tres = 128
args = [
! #[tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! # ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
! "seed", "1412"]],
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
! "seed", "141265"]],
! [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
! ["turb", "1", "scale", ".3", "freq", "1",
! "freq2", "100", "df", "2", "bias", "0"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "0"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "1"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "2"]],
! [2, 2, 0, 4, "RGBA", "RGBA", "geometric", ["type", "3"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"]],
! [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "5"]],
! [2, 2, 0, 4, "RGBA", "RGBA", "geometric", ["type", "6"]],
! ]
from gfx.libpaper.textures import getCachedTexture
Index: gzz/gfx/libpaper/papermill.py
diff -c gzz/gfx/libpaper/papermill.py:1.39 gzz/gfx/libpaper/papermill.py:1.40
*** gzz/gfx/libpaper/papermill.py:1.39 Mon Oct 7 14:30:46 2002
--- gzz/gfx/libpaper/papermill.py Wed Oct 9 10:07:27 2002
***************
*** 173,179 ****
if dbg: print "Texture"+str(i)+":", t.getName()
! sh.setTexture(i, t.getTexId())
if emboss:
comb = EmbossCombinerPass()
--- 173,179 ----
if dbg: print "Texture"+str(i)+":", t.getName()
! sh.setTexture(i, t)
if emboss:
comb = EmbossCombinerPass()
***************
*** 205,211 ****
code += (
sh.setupCode() +
! comb.setupCode(sh.getRGBoutputs(), colors, rnd, trans)
)
ppass.setSetupcode(code)
--- 205,211 ----
code += (
sh.setupCode() +
! comb.setupCode(sh.getRGBoutputs(), sh.getRGBoutputscales(),
colors, rnd, trans)
)
ppass.setSetupcode(code)
Index: gzz/gfx/libpaper/texcomb_NV1X.py
diff -c gzz/gfx/libpaper/texcomb_NV1X.py:1.16
gzz/gfx/libpaper/texcomb_NV1X.py:1.17
*** gzz/gfx/libpaper/texcomb_NV1X.py:1.16 Fri Oct 4 09:18:18 2002
--- gzz/gfx/libpaper/texcomb_NV1X.py Wed Oct 9 10:07:27 2002
***************
*** 6,12 ****
from gfx.libcolor.spaces import RGBtoLAB
class TransparentCombinerPass:
! def setupCode(self, texinputs, colors, rnd, trans = 0):
# 4 colors
colorbase = rnd.nextInt()
c0, c1, c2, c3 = [ colors.getColorStr(colorbase+i)
--- 6,12 ----
from gfx.libcolor.spaces import RGBtoLAB
class TransparentCombinerPass:
! def setupCode(self, texinputs, texscales, colors, rnd, trans = 0):
# 4 colors
colorbase = rnd.nextInt()
c0, c1, c2, c3 = [ colors.getColorStr(colorbase+i)
***************
*** 51,115 ****
type = rnd.nextInt(3)
# types: 0=BAND-LIKE, 1=3-COL-LERP, 2=FRACTION-LINE
! if 0:
! if trans > 0:
! scale = "SCALE_BY_FOUR_NV"
! else:
! scale = [ "SCALE_BY_ONE_HALF_NV",
! "NONE",
! "SCALE_BY_TWO_NV",
! "SCALE_BY_FOUR_NV",
! ][rnd.nextInt(4)]
!
!
# Then, select the combiner path type.
! if 0:
! # Stage 0: calculate dot products of the textures, and of
! # a texture times a constant.
! c = ("""
! CI0 RGB A TEXTURE%(t0)s EXPAND_NORMAL_NV RGB
! CI0 RGB B TEXTURE%(t1)s EXPAND_NORMAL_NV RGB
! CI0 RGB C CONSTANT_COLOR0_NV EXPAND_NORMAL_NV RGB
! CI0 RGB D TEXTURE%(t2)s EXPAND_NORMAL_NV RGB
! CO0 RGB SPARE0_NV SPARE1_NV DISCARD_NV SCALE_BY_TWO_NV NONE
TRUE TRUE FALSE
!
! CI0 ALPHA A TEXTURE%(t0)s EXPAND_NORMAL_NV BLUE
! CI0 ALPHA B TEXTURE%(t1)s EXPAND_NORMAL_NV BLUE
! CI0 ALPHA C TEXTURE%(t0)s EXPAND_NORMAL_NV ALPHA
! CI0 ALPHA D TEXTURE%(t1)s EXPAND_NORMAL_NV ALPHA
! CO0 ALPHA SPARE0_NV DISCARD_NV DISCARD_NV SCALE_BY_FOUR_NV NONE
FALSE FALSE FALSE
!
!
!
! """+
! # Stage 1: mix primary and secondary as determined
! # by the dot product above.
! """
! CI1 RGB A PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB B SPARE0_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB C SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB D SPARE0_NV UNSIGNED_INVERT_NV RGB
! CO1 RGB DISCARD_NV DISCARD_NV PRIMARY_COLOR_NV NONE NONE FALSE
FALSE FALSE
!
! CI1 ALPHA A SPARE0_NV UNSIGNED_INVERT_NV BLUE
! CI1 ALPHA B SPARE0_NV SIGNED_IDENTITY_NV ALPHA
! CO1 ALPHA SPARE0_NV DISCARD_NV DISCARD_NV SCALE_BY_FOUR_NV NONE
FALSE FALSE FALSE
!
! """+
! """
! FCI A SPARE1_NV UNSIGNED_IDENTITY_NV RGB
! FCI B PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! FCI C FOG UNSIGNED_IDENTITY_NV RGB
! FCI D ZERO UNSIGNED_IDENTITY_NV RGB
!
! FCI G SPARE0_NV UNSIGNED_INVERT_NV ALPHA
!
! """)
! elif type == 0:
! #scale = "SCALE_BY_ONE_HALF_NV"
! #scale = "NONE"
! #scale = "SCALE_BY_TWO_NV"
! scale = "SCALE_BY_FOUR_NV"
# Band-like texture.
#
--- 51,64 ----
type = rnd.nextInt(3)
# types: 0=BAND-LIKE, 1=3-COL-LERP, 2=FRACTION-LINE
! def avg(*args):
! sum = 0
! for arg in args: sum += arg
! return sum / float(len(args))
!
# Then, select the combiner path type.
! if type == 0:
! scale = nvcode.combinerscale(avg(*texscales) * 8.0)
# Band-like texture.
#
***************
*** 152,162 ****
FCI G %(finalG)s UNSIGNED_INVERT_NV BLUE
""")
elif type == 1:
! #scale = "SCALE_BY_ONE_HALF_NV"
! #scale = "NONE"
! #scale = "SCALE_BY_TWO_NV"
! scale = "SCALE_BY_FOUR_NV"
!
# Interpolate between three colors:
# d0 = t0 . r0
# d1 = t1 . r1
--- 101,109 ----
FCI G %(finalG)s UNSIGNED_INVERT_NV BLUE
""")
elif type == 1:
! scale = nvcode.combinerscale(avg(*texscales) * 8.0)
! alphascale = nvcode.combinerscale(1.0)
!
# Interpolate between three colors:
# d0 = t0 . r0
# d1 = t1 . r1
***************
*** 191,197 ****
CI1 ALPHA B SPARE0_NV SIGNED_IDENTITY_NV BLUE
CI1 ALPHA C SPARE1_NV SIGNED_NEGATE_NV BLUE
CI1 ALPHA D SPARE1_NV SIGNED_IDENTITY_NV BLUE
! CO1 ALPHA DISCARD_NV DISCARD_NV SPARE1_NV %(scale)s NONE
FALSE FALSE FALSE
# lerp(SPARE1, PRI_COL, FOG)
FCI A SPARE1_NV UNSIGNED_INVERT_NV RGB
--- 138,144 ----
CI1 ALPHA B SPARE0_NV SIGNED_IDENTITY_NV BLUE
CI1 ALPHA C SPARE1_NV SIGNED_NEGATE_NV BLUE
CI1 ALPHA D SPARE1_NV SIGNED_IDENTITY_NV BLUE
! CO1 ALPHA DISCARD_NV DISCARD_NV SPARE1_NV %(alphascale)s NONE
FALSE FALSE FALSE
# lerp(SPARE1, PRI_COL, FOG)
FCI A SPARE1_NV UNSIGNED_INVERT_NV RGB
***************
*** 202,211 ****
FCI G %(finalG)s ALPHA
""")
else:
! #scale = "SCALE_BY_ONE_HALF_NV"
! #scale = "NONE"
! #scale = "SCALE_BY_TWO_NV"
! scale = "SCALE_BY_FOUR_NV"
# Interpolate on the fraction line c0,c1,c2:
# d0 = t0 . t1
--- 149,155 ----
FCI G %(finalG)s ALPHA
""")
else:
! scale = nvcode.combinerscale(avg(*texscales) * 4.0)
# Interpolate on the fraction line c0,c1,c2:
# d0 = t0 . t1
Index: gzz/gfx/libpaper/texops_STD.py
diff -c gzz/gfx/libpaper/texops_STD.py:1.3 gzz/gfx/libpaper/texops_STD.py:1.4
*** gzz/gfx/libpaper/texops_STD.py:1.3 Sat Sep 14 06:22:28 2002
--- gzz/gfx/libpaper/texops_STD.py Wed Oct 9 10:07:27 2002
***************
*** 17,31 ****
return [texunit[1] for texunit in self.st]
def getTexgenTypes(self):
return [texunit[2] for texunit in self.st]
! def setTexture(self, ind, texid):
! self.tex[ind] = str(texid)
def getRGBoutputs(self):
return [i for i in range(0,len(self.st))]
def setupCode(self):
c = ""
for t in range(0,len(self.st)):
target = self.st[t][0]
! texid = self.tex[t]
if texid == None: raise NoTextureSetForStage()
c += """
ActiveTexture TEXTURE%(t)s
--- 17,35 ----
return [texunit[1] for texunit in self.st]
def getTexgenTypes(self):
return [texunit[2] for texunit in self.st]
! def setTexture(self, ind, tex):
! self.tex[ind] = tex
def getRGBoutputs(self):
return [i for i in range(0,len(self.st))]
+ def getRGBoutputscales(self):
+ return [self.tex[i].scale for i in range(0,len(self.st))]
def setupCode(self):
c = ""
for t in range(0,len(self.st)):
target = self.st[t][0]
! texid = self.tex[t].getTexId()
! minfilter = self.tex[t].minfilter
! magfilter = self.tex[t].magfilter
if texid == None: raise NoTextureSetForStage()
c += """
ActiveTexture TEXTURE%(t)s
***************
*** 39,46 ****
TexParameter %(target)s TEXTURE_WRAP_S REPEAT
TexParameter %(target)s TEXTURE_WRAP_T REPEAT
! TexParameter %(target)s TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
! TexParameter %(target)s TEXTURE_MAG_FILTER LINEAR
""" % locals()
return c
--- 43,50 ----
TexParameter %(target)s TEXTURE_WRAP_S REPEAT
TexParameter %(target)s TEXTURE_WRAP_T REPEAT
! TexParameter %(target)s TEXTURE_MIN_FILTER %(minfilter)s
! TexParameter %(target)s TEXTURE_MAG_FILTER %(magfilter)s
""" % locals()
return c
Index: gzz/gfx/libpaper/textures.py
diff -c gzz/gfx/libpaper/textures.py:1.20 gzz/gfx/libpaper/textures.py:1.21
*** gzz/gfx/libpaper/textures.py:1.20 Wed Oct 9 06:32:18 2002
--- gzz/gfx/libpaper/textures.py Wed Oct 9 10:07:27 2002
***************
*** 57,62 ****
--- 57,64 ----
def __init__(self, dict):
# Add default values below
self.continuous = 1
+ self.minfilter = "LINEAR_MIPMAP_LINEAR"
+ self.magfilter = "LINEAR"
# Update from specified values
self.__dict__.update(dict)
***************
*** 76,86 ****
initialized = 1
global ptextures
ptextures["RGB2"] = map(NamedTexture, [
! {"name" : "rgbw1",
! "args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
! ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
! "scale" : 1./8,
! },
{"name" : "rgbw2",
"args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
--- 78,88 ----
initialized = 1
global ptextures
ptextures["RGB2"] = map(NamedTexture, [
! # {"name" : "rgbw1",
! # "args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
! # ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
! # "scale" : 1./8,
! # },
{"name" : "rgbw2",
"args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
***************
*** 102,110 ****
},
{"name" : "checkerboard",
! "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "1"]],
"continuous" : 0,
! "scale" : 1./64,
},
{"name" : "cone",
--- 104,114 ----
},
{"name" : "checkerboard",
! "args" : [4, 4, 0, 3, "RGB", "RGB", "geometric", ["type", "1",
"scale", ".5", "bias", ".5"]],
"continuous" : 0,
! "scale" : 1./8,
! "minfilter" : "NEAREST",
! "magfilter" : "NEAREST",
},
{"name" : "cone",
***************
*** 113,132 ****
},
{"name" : "checkerboard2",
! "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "3"]],
"continuous" : 0,
! "scale" : 1./64,
},
{"name" : "saw",
"args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "4"]],
"continuous" : 0,
! "scale" : 1./64,
},
{"name" : "triangle",
"args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "5"]],
"scale" : 1./2,
},
])
--- 117,148 ----
},
{"name" : "checkerboard2",
! "args" : [2, 2, 0, 3, "RGB", "RGB", "geometric", ["type", "3",
"scale", ".5", "bias", ".5"]],
"continuous" : 0,
! "scale" : 1./8,
! "minfilter" : "NEAREST",
! "magfilter" : "NEAREST",
},
{"name" : "saw",
"args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "4"]],
"continuous" : 0,
! "scale" : 1./8,
! "minfilter" : "NEAREST",
! "magfilter" : "NEAREST",
},
{"name" : "triangle",
"args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "5"]],
"scale" : 1./2,
+ },
+
+ {"name" : "stripe",
+ "args" : [2, 2, 0, 3, "RGB", "RGB", "geometric", ["type", "6",
"scale", ".5", "bias", ".5"]],
+ "continuous" : 0,
+ "scale" : 1./8,
+ "minfilter" : "NEAREST",
+ "magfilter" : "NEAREST",
},
])
Index: gzz/gfx/libtexture/geometric.texture
diff -c gzz/gfx/libtexture/geometric.texture:1.3
gzz/gfx/libtexture/geometric.texture:1.4
*** gzz/gfx/libtexture/geometric.texture:1.3 Tue Oct 8 12:09:54 2002
--- gzz/gfx/libtexture/geometric.texture Wed Oct 9 10:07:27 2002
***************
*** 46,53 ****
return 1 - 2 * fabs(x - .5);
}
void GENERATE(TextureParam *params, int width, int height, int depth, int
components, float *data) {
! FPARAM(type, 0)
if(components > 4) return;
--- 46,60 ----
return 1 - 2 * fabs(x - .5);
}
+ float stripe(float x) {
+ x -= floor(x);
+ return (x < .4999999);
+ }
+
void GENERATE(TextureParam *params, int width, int height, int depth, int
components, float *data) {
! FPARAM(type, 0);
! FPARAM(scale, 1);
! FPARAM(bias, 0);
if(components > 4) return;
***************
*** 97,105 ****
--- 104,122 ----
if (components >= 3) data[ind++] = triangle(y);
if (components >= 4) data[ind++] = triangle(.5 + y);
break;
+ case 6:
+ if (components >= 1) data[ind++] = stripe(x);
+ if (components >= 2) data[ind++] = stripe(1 - xstep - x);
+ if (components >= 3) data[ind++] = stripe(y);
+ if (components >= 4) data[ind++] = stripe(1 - ystep - y);
+ break;
}
}
}
+ for(int i = 0; i < width * height * depth * components; i++) {
+ data[i] = data[i] * scale + bias;
+ }
+
}
Index: gzz/gfx/libutil/nvcode.py
diff -c gzz/gfx/libutil/nvcode.py:1.1 gzz/gfx/libutil/nvcode.py:1.2
*** gzz/gfx/libutil/nvcode.py:1.1 Tue Sep 10 14:53:37 2002
--- gzz/gfx/libutil/nvcode.py Wed Oct 9 10:07:27 2002
***************
*** 15,17 ****
--- 15,24 ----
replace(" F ", " VARIABLE_F_NV ").
replace(" G ", " VARIABLE_G_NV ")
)
+
+ # return the NV_register_combiner scale that matches x best
+ def combinerscale(x):
+ if x < .75: return "SCALE_BY_ONE_HALF_NV"
+ elif x < 1.5: return "NONE"
+ elif x < 3: return "SCALE_BY_TWO_NV"
+ return "SCALE_BY_FOUR_NV"