So, in the way we do Sobel, we need 8 textures plus the original image. We also need a way of counting the alive or dead neighbours. It's fairly simple. I will let you figure it out from the code. The game of life rules I got from here: https://www.theguardian.com/science/alexs-adventures-in-numberland/2014/dec/15/the-game-of-life-a-beginners-guide
bool isAlive(float3 colour) { return (colour.r + colour.g + colour.b) / 3.0f < 0.5f; } bool isAlive4(float4 colour) { return (colour.r + colour.g + colour.b) / 3.0f < 0.5f; } float3 decideLife(int aliveCount, float3 colour) { float3 dead = float3(1.0, 1.0, 1.0); float3 alive = float3(0.0, 0.0, 0.0); if(isAlive(colour)) { if(aliveCount < 2) return dead; else if(aliveCount < 4) return alive; return dead; } if(aliveCount == 3) return alive; return dead; } float3 checkNeighbourhood(float3 colour, float2 texcoord) { int aliveCount = 0; float4 top = tex2D(s0, float2(texcoord.x, texcoord.y + INV_HEIGHT)); float4 bottom = tex2D(s0, float2(texcoord.x, texcoord.y - INV_HEIGHT)); float4 left = tex2D(s0, float2(texcoord.x - INV_WIDTH, texcoord.y)); float4 right = tex2D(s0, float2(texcoord.x + INV_WIDTH, texcoord.y)); float4 tl = tex2D(s0, float2(texcoord.x - INV_WIDTH, texcoord.y + INV_HEIGHT)); float4 tr = tex2D(s0, float2(texcoord.x + INV_WIDTH, texcoord.y + INV_HEIGHT)); float4 bl = tex2D(s0, float2(texcoord.x - INV_WIDTH, texcoord.y - INV_HEIGHT)); float4 br = tex2D(s0, float2(texcoord.x + INV_WIDTH, texcoord.y - INV_HEIGHT)); if(isAlive4(top)) aliveCount++; if(isAlive4(bottom)) aliveCount++; if(isAlive4(left)) aliveCount++; if(isAlive4(right)) aliveCount++; if(isAlive4(tl)) aliveCount++; if(isAlive4(tr)) aliveCount++; if(isAlive4(bl)) aliveCount++; if(isAlive4(br)) aliveCount++; return decideLife(aliveCount, colour); }