Skip to content

Instantly share code, notes, and snippets.

@nnarain
Created November 10, 2014 19:10
Show Gist options
  • Save nnarain/f8a019ebd0f411653433 to your computer and use it in GitHub Desktop.
Save nnarain/f8a019ebd0f411653433 to your computer and use it in GitHub Desktop.
Basic OpenGL 3.1 Shaders
// Basic OpenGL Shaders
out vec3 fragColor;
in vec3 wsVertexPosition;
in vec3 msFragNormal;
uniform mat4 M;
uniform mat4 V;
uniform mat4 MVP;
uniform mat3 N;
void main()
{
vec3 n = normalize(N * msFragNormal);
vec3 color = n;
if(color.x < 0) color.x * (-1);
if(color.y < 0) color.y * (-1);
if(color.z < 0) color.z * (-1);
fragColor = color;
}
// Basic OpenGL Shaders
in vec3 msVertexPosition;
in vec3 msVertexNormal;
out vec3 wsVertexPosition;
out vec3 msFragNormal;
uniform mat4 M;
uniform mat4 V;
uniform mat4 MVP;
uniform mat3 N;
void main()
{
wsVertexPosition = M * vec4(msVertexPosition, 1);
msFragNormal = msVertexNormal;
gl_Position = wsVertexPosition;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment