Last active
January 19, 2017 08:06
-
-
Save ykob/38a48bd2752e13f3e2c1d8bcf173d6da 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
uniform vec3 light_direction; | |
varying vec3 vPosition; | |
varying vec3 vColor; | |
varying mat4 vInvertMatrix; | |
void main() { | |
vec3 normal = normalize(cross(dFdx(vPosition), dFdy(vPosition))); | |
vec3 inv_light = normalize(vInvertMatrix * vec4(light_direction, 1.0)).xyz; | |
float diff = clamp(dot(normal, inv_light), 0.0, 1.0); | |
gl_FragColor = vec4(vColor * diff, 1.0); | |
} |
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
attribute vec3 position; | |
attribute vec3 color; | |
uniform mat4 modelMatrix; | |
uniform mat4 modelViewMatrix; | |
uniform mat4 projectionMatrix; | |
varying vec3 vPosition; | |
varying vec3 vColor; | |
varying mat4 vInvertMatrix; | |
#pragma glslify: inverse = require(glsl-inverse); | |
void main() { | |
vPosition = position; | |
vPosition = color; | |
vInvertMatrix = inverse(modelMatrix); | |
gl_Position = projectionMatrix * modelViewMatrix * position; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment