Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GunnarKarlsson/06d64597b52f2dabe988a61fe80b6c4c to your computer and use it in GitHub Desktop.
Save GunnarKarlsson/06d64597b52f2dabe988a61fe80b6c4c to your computer and use it in GitHub Desktop.
Fragment shader: square follows mouse
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec3 col1 = vec3(0.5, 0.5, 0.5);
vec3 col2 = vec3(0.0, 1.0, 1.0);
vec3 col = col1;
if (fragCoord.x > iMouse.x - 30.0 &&
fragCoord.x < iMouse.x + 30.0 &&
fragCoord.y > iMouse.y - 30.0 &&
fragCoord.y < iMouse.y + 30.0) {
col = col2;
}
fragColor = vec4(col,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment