-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconwaylife.cg
27 lines (25 loc) · 1.01 KB
/
conwaylife.cg
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
struct output{
float4 color : COLOR;
};
output main(float2 position : POSITION, float2 texCoord : TEXCOORD, uniform float sze, uniform sampler2D lastTex, uniform float var1)
{
output OUT;
float d = 1.0 / sze;
float4 lastCol = tex2D(lastTex, texCoord);
int upCount = floor(tex2D(lastTex, float2(texCoord.x - d, texCoord.y - d)).b) +
floor( tex2D(lastTex, float2(texCoord.x, texCoord.y - d)).b) +
floor(tex2D(lastTex, float2(texCoord.x + d, texCoord.y - d)).b) +
floor(tex2D(lastTex, float2(texCoord.x - d, texCoord.y)).b) +
floor(tex2D(lastTex, float2(texCoord.x + d, texCoord.y)).b) +
floor(tex2D(lastTex, float2(texCoord.x - d, texCoord.y + d)).b) +
floor(tex2D(lastTex, float2(texCoord.x, texCoord.y + d)).b) +
floor(tex2D(lastTex, float2(texCoord.x + d, texCoord.y + d)).b);
if((upCount == 2 && lastCol.b == 1.0) || upCount == 3){
OUT.color = float4(texCoord.x, texCoord.y, 1, 1);
// OUT.color = floatr4(1, 1, 1, 1);
}
else{
OUT.color = float4(0, 0, 0, 1);
}
return OUT;
}