uniform sampler2D uTexture; varying vec2 vUv; #define STEP 0.03125 void main() { vec4 here = texture2D( uTexture, vUv ); vec4 below = texture2D( uTexture, vUv - vec2( 0.0, STEP ) ); bool alive = here.r > 0.5; bool solidBelow = below.g > 0.5; if ( alive && solidBelow ) { here.rg = here.gr; } gl_FragColor = here; }