Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Vertex Shader
- attribute vec3 inPosition;
- attribute vec3 inNormal;
- uniform vec4 m_Color;
- uniform mat4 g_WorldViewProjectionMatrix;
- uniform mat4 g_WorldViewMatrix;
- uniform mat3 g_NormalMatrix;
- varying vec4 vertColor;
- void main() {
- gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
- //vec3 lightDir = vec3(g_WorldViewMatrix * vec4(gl_LightSource[0].position));
- vec3 lightDir = vec3(gl_LightSource[0].position);
- //vec3 lightDir = vec3(-1.0, -1.0, -1.0);
- vec3 normal = g_NormalMatrix * inNormal;
- float factor = dot(-1 * lightDir, normal);
- vertColor = m_Color * factor;
- }
- // Fragment Shader (just a passthrough)
- varying vec4 vertColor;
- void main() {
- gl_FragColor = vertColor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement