Skip to content

Instantly share code, notes, and snippets.

@smw
Created May 6, 2014 05:23
Show Gist options
  • Save smw/fe8a2497734358e15beb to your computer and use it in GitHub Desktop.
Save smw/fe8a2497734358e15beb to your computer and use it in GitHub Desktop.
layout(location = 0) uniform mat4 transformationMatrix;
layout(location = 1) uniform mat4 projectionMatrix;
layout(location = 2) uniform mat3 normalMatrix;
layout(location = 3) uniform vec3 light;
layout(location = 0) in vec4 position;
layout(location = 2) in mediump vec3 normal;
out mediump vec3 transformedNormal;
out highp vec3 lightDirection;
out highp vec3 cameraDirection;
void main() {
/* Transformed vertex position */
highp vec4 transformedPosition4 = transformationMatrix*position;
highp vec3 transformedPosition = transformedPosition4.xyz/transformedPosition4.w;
/* Transformed normal vector */
transformedNormal = normalMatrix*normal;
/* Direction to the light */
lightDirection = normalize(light - transformedPosition);
/* Direction to the camera */
cameraDirection = -transformedPosition;
/* Transform the position */
gl_Position = projectionMatrix*transformedPosition4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment