4 |
from gfx.libutil import nvcode |
from gfx.libutil import nvcode |
5 |
|
|
6 |
from gfx.libcolor.spaces import RGBtoLAB |
from gfx.libcolor.spaces import RGBtoLAB |
7 |
|
|
8 |
|
from math import exp |
9 |
|
|
10 |
class TransparentCombinerPass: |
class TransparentCombinerPass: |
11 |
def setupCode(self, texinputs, texscales, colors, rnd, trans = 0): |
def setupCode(self, texinputs, texscales, colors, rnd, trans = 0): |
53 |
type = rnd.nextInt(3) |
type = rnd.nextInt(3) |
54 |
# types: 0=BAND-LIKE, 1=3-COL-LERP, 2=FRACTION-LINE |
# types: 0=BAND-LIKE, 1=3-COL-LERP, 2=FRACTION-LINE |
55 |
|
|
56 |
|
# Random scaling of (dot) products |
57 |
|
rndscale1 = exp(.3*rnd.nextGaussian()) |
58 |
|
rndscale2 = exp(.3*rnd.nextGaussian()) |
59 |
|
|
60 |
def avg(*args): |
def avg(*args): |
61 |
sum = 0 |
sum = 0 |
62 |
for arg in args: sum += arg |
for arg in args: sum += arg |
64 |
|
|
65 |
# Then, select the combiner path type. |
# Then, select the combiner path type. |
66 |
if type == 0: |
if type == 0: |
67 |
scale = nvcode.combinerscale(avg(*texscales) * 8.0) |
scale = nvcode.combinerscale(avg(*texscales) * 8.0 * rndscale1) |
68 |
|
|
69 |
# Band-like texture. |
# Band-like texture. |
70 |
# |
# |
107 |
FCI G %(finalG)s UNSIGNED_INVERT_NV BLUE |
FCI G %(finalG)s UNSIGNED_INVERT_NV BLUE |
108 |
""") |
""") |
109 |
elif type == 1: |
elif type == 1: |
110 |
scale = nvcode.combinerscale(avg(*texscales) * 8.0) |
scale = nvcode.combinerscale(avg(*texscales) * 8.0 * rndscale1) |
111 |
alphascale = nvcode.combinerscale(1.0) |
alphascale = nvcode.combinerscale(1.0) |
112 |
|
|
113 |
# Interpolate between three colors: |
# Interpolate between three colors: |
155 |
FCI G %(finalG)s ALPHA |
FCI G %(finalG)s ALPHA |
156 |
""") |
""") |
157 |
else: |
else: |
158 |
scale = nvcode.combinerscale(avg(*texscales) * 4.0) |
scale = nvcode.combinerscale(avg(*texscales) * 4.0 * rndscale1) |
159 |
|
|
160 |
# Interpolate on the fraction line c0,c1,c2: |
# Interpolate on the fraction line c0,c1,c2: |
161 |
# d0 = t0 . t1 |
# d0 = t0 . t1 |