Created
December 20, 2020 07:50
-
-
Save AhmadMoussa/3bc42f30fc14f6e016eef573bcf336bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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