35 |
{0, 0, 0, 1}, |
{0, 0, 0, 1}, |
36 |
}; |
}; |
37 |
|
|
38 |
|
float2 inters(float2 what) { |
39 |
|
float2 ctr = float2(.5,.5); |
40 |
|
float2 vec = what-ctr; |
41 |
|
float2 a = abs(vec); |
42 |
|
// if(a.x + a.y < .001) return float4(0,0,0,1); |
43 |
|
float mul; |
44 |
|
if(a.x > a.y) { |
45 |
|
mul = .5 / a.x; |
46 |
|
} else { |
47 |
|
mul = .5 / a.y; |
48 |
|
} |
49 |
|
return ctr + vec * mul; |
50 |
|
} |
51 |
|
|
52 |
void main( |
void main( |
53 |
float4 t: TEXCOORD0, |
float4 t: TEXCOORD0, |
54 |
float4 pos: POSITION, |
float4 pos: POSITION, |
55 |
out float4 opos: POSITION, |
out float4 opos: POSITION, |
56 |
out float4 ocol : TEXCOORD0 |
out float4 ocol : TEXCOORD0 |
57 |
) { |
) { |
58 |
float4 ctr1 = mul(glstate.matrix.program[0], float4(.5,.5,0,1)); |
float4 ctr = float4(.5,.5,0,1); |
59 |
float4 ctr2 = mul(glstate.matrix.program[1], float4(.5,.5,0,1)); |
float4 ctr1 = mul(glstate.matrix.program[0], ctr); |
60 |
|
float4 ctr2 = mul(glstate.matrix.program[1], ctr); |
61 |
|
|
62 |
|
float4 ctr1_in2 = mul(glstate.matrix.inverse.program[1], ctr1); |
63 |
|
float4 ctr2_in1 = mul(glstate.matrix.inverse.program[0], ctr2); |
64 |
|
|
65 |
|
// Solve eq: find intersections of unit squares |
66 |
|
float2 inters1 = inters(ctr2_in1.xy); |
67 |
|
float2 inters2 = inters(ctr1_in2.xy); |
68 |
|
// float2 inters1 = ctr.xy; |
69 |
|
// float2 inters2 = ctr.xy; |
70 |
|
|
71 |
float inter = frac(4*pos.x); |
float inter = frac(4*pos.x); |
72 |
float edgeind = fmod(floor(4*pos.x), 4) ; |
float edgeind = fmod(floor(4*pos.x), 4) ; |
73 |
|
|
74 |
|
|
75 |
float4 xa = float4(0,0,0,1); |
float2 xa = float2(0,0); |
76 |
float4 xb = float4(0,0,0,1); |
float2 xb = float2(0,0); |
77 |
|
|
78 |
xa.x = (edgeind >= 2 && edgeind < 4); |
xa.x = (edgeind >= 2 && edgeind < 4); |
79 |
xa.y = (edgeind >= 1 && edgeind < 3); |
xa.y = (edgeind >= 1 && edgeind < 3); |
88 |
*/ |
*/ |
89 |
|
|
90 |
|
|
91 |
float4 x = lerp(xa, xb, inter); |
float2 x = lerp(xa, xb, inter); |
92 |
// x = float4(pos.x, 0, 0, 1); |
// x = float4(pos.x, 0, 0, 1); |
93 |
|
|
94 |
float shri = 3.7*(pos.y - pos.y*pos.y); |
float shri = 3.7*(pos.y - pos.y*pos.y); |
95 |
|
|
96 |
x = lerp(x, float4(.5, .5, 0, 1), shri); |
float4 sx1; |
97 |
|
float4 sx2; |
98 |
|
sx1.xy = lerp(x, inters1, shri); |
99 |
|
sx2.xy = lerp(x, inters2, shri); |
100 |
|
|
101 |
|
sx1.z = 0; |
102 |
|
sx1.w = 1; |
103 |
|
sx2.z = 0; |
104 |
|
sx2.w = 1; |
105 |
|
|
106 |
float4 x1 = mul(glstate.matrix.program[0], x); |
float4 x1 = mul(glstate.matrix.program[0], sx1); |
107 |
float4 x2 = mul(glstate.matrix.program[1], x); |
float4 x2 = mul(glstate.matrix.program[1], sx2); |
108 |
|
|
109 |
float4 p = lerp(x1, x2, pos.y); |
float4 p = lerp(x1, x2, pos.y); |
110 |
|
|
127 |
ocol.xy = pos.xy; |
ocol.xy = pos.xy; |
128 |
ocol.z = shri; |
ocol.z = shri; |
129 |
|
|
130 |
ocol.w = min(pin1, pin2); |
ocol.w = min(pin1, pin2).x; |
131 |
|
|
132 |
// ocol.w = .5; |
// ocol.w = .5; |
133 |
// oc.z = 1; |
// oc.z = 1; |
143 |
uniform sampler2D t0: TEXUNIT0, |
uniform sampler2D t0: TEXUNIT0, |
144 |
uniform sampler2D t1: TEXUNIT1 |
uniform sampler2D t1: TEXUNIT1 |
145 |
) { |
) { |
146 |
|
// Don't render inside the rectangles |
147 |
|
// if(p.w < 1) discard; |
148 |
|
|
149 |
float3 dark = float3(186, 71, 18) / 255.0; |
float3 dark = float3(186, 71, 18) / 255.0; |
150 |
float3 light = float3(249, 233, 50) / 255.0; |
float3 light = float3(249, 233, 50) / 255.0; |
151 |
|
|
152 |
float4 dtex = tex2D(t0, p.xy * float2(4, 2)); |
float4 dtex = tex2D(t0, p.xy * float2(7, .1)); |
153 |
float4 atex = tex2D(t1, p.xy * float2(2, 2)); |
float4 atex = tex2D(t1, p.xy * float2(2, 2)); |
154 |
|
|
155 |
ocol.xyz = lerp(dark, light, dtex.x); |
ocol.xyz = lerp(dark, light, dtex.x); |
168 |
self.key = KeyPresses( |
self.key = KeyPresses( |
169 |
self, |
self, |
170 |
SlideLin("x", 400, 50, "x coord", "Left", "Right"), |
SlideLin("x", 400, 50, "x coord", "Left", "Right"), |
171 |
SlideLin("y", 400, 10, "x coord", "Up", "Down"), |
SlideLin("y", 400, 50, "y coord", "Up", "Down"), |
172 |
SlideLin("a", 0, 15, "Rotation", "Prior", "Next"), |
SlideLin("a", 0, 15, "Rotation", "Prior", "Next"), |
173 |
) |
) |
174 |
def scene(self, vs): |
def scene(self, vs): |
213 |
""" % ( |
""" % ( |
214 |
vp[0].getProgId(), |
vp[0].getProgId(), |
215 |
fp[0].getProgId(), |
fp[0].getProgId(), |
216 |
turb.getTexId(), |
noise.getTexId(), |
217 |
lnoise.getTexId(), |
lnoise.getTexId(), |
218 |
))) |
))) |
219 |
|
|