-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmandelsend.cg
More file actions
42 lines (40 loc) · 1.17 KB
/
Copy pathmandelsend.cg
File metadata and controls
42 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
struct output{
float4 color : COLOR;
};
output main(float2 position : POSITION, float2 texCoord : TEXCOORD, uniform float sze, uniform sampler2D lastTex, uniform sampler2D audioTex, uniform float var1, uniform float var2)
{
// output OUT;
// if(tex2D(audioTex, texCoord).b > 0.5){
// OUT.color = float4(texCoord.x, texCoord.y, 1, 1);
// }
// else{
// float2 p = float2(2*texCoord.x - 1, 1 - 2*texCoord.y);
// float2 c = float2(p);
// for(int i = 0; i < 10; i++)
// p = float2(p.x * p.x - p.y * p.y + c.x, 2 * p.x * p.y + c.y);
// p = float2((p.x + 1)/2, (1 - p.y)/2);
// if(tex2D(audioTex, p).b > 0.5)
// OUT.color = float4(p.x, p.y, 1, 1);
// else OUT.color = tex2D(lastTex, texCoord) - 0.002;
// }
// return OUT;
output OUT;
float2 tc = float2(texCoord);
float2 p = float2(2*tc.x - 1, 1 - 2*tc.y);
float2 c = float2(p);
int i;
int iter = 10;
for(i = 0; i < iter; i++){
if(tex2D(audioTex, tc).b > 0.5){
OUT.color = float4(texCoord.x, texCoord.y, 1, 1);
break;
}
else{
p = var1*float2(p.x * p.x - p.y * p.y + c.x, 2 * p.x * p.y + c.y);
tc = float2((p.x + 1)/2, (1 - p.y)/2);
}
}
if(i == iter)
OUT.color = tex2D(lastTex, texCoord) - 0.02;
return OUT;
}