Created
July 19, 2019 05:38
-
-
Save AlainBarrios/50e1e785b455b34b1d8fe79bfffc11fa to your computer and use it in GitHub Desktop.
This file contains 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
vec2 uv = vTextureCoord; | |
vec2 m = uMouse / uReso; | |
vec3 lightAmbient = vec3(.2, .2, .2 ); | |
vec4 lightColor = vec4(1., 1., 1., 1.3); | |
vec3 lightPos = vec3(uv - m, .1); | |
vec3 color = texture2D(texture0, uv).xyz; | |
vec3 normalMap = texture2D(map, uv).xyz - .5; | |
vec3 diff = lightColor.rgb * lightColor.a * max(dot(normalize(normalMap), normalize(lightPos)), 0.); | |
float d = distance(m, uv); | |
float att = 1. - pow(clamp(d / 10., 0., 1.), .5); | |
vec3 totalLight = diff * att; | |
gl_FragColor = vec4(color * totalLight, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment