Skip to content

Instantly share code, notes, and snippets.

@AhmadMoussa
Created December 20, 2020 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AhmadMoussa/3bc42f30fc14f6e016eef573bcf336bd to your computer and use it in GitHub Desktop.
Save AhmadMoussa/3bc42f30fc14f6e016eef573bcf336bd to your computer and use it in GitHub Desktop.
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
float rectshape(vec2 position, vec2 scale){
scale = vec2(0.5) - scale * 0.5;
vec2 shaper = vec2(step(scale.x, position.x), step(scale.y, position.y));
shaper *= vec2(step(scale.x, 1.0 - position.x), step(scale.y, 1.0 - position.y));
return shaper.x * shaper.y;
}
uniform float u_time;
uniform vec2 u_mouse;
void main(){
vec2 position = gl_FragCoord.xy / u_resolution;
vec3 color = vec3(0.0);
vec3 c = vec3(1.0,0.3,0.3);
vec2 mp = vec2(u_mouse.x/gl_FragCoord.x,u_mouse.y/gl_FragCoord.y);
float rectangle = rectshape(mp, vec2(0.2,0.2));
color = vec3(rectangle);
vec3 rect_color = mix(color,c,color*0.5);
gl_FragColor = vec4(rect_color, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment