Created
November 10, 2014 19:10
-
-
Save nnarain/f8a019ebd0f411653433 to your computer and use it in GitHub Desktop.
Basic OpenGL 3.1 Shaders
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
// 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; | |
} |
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
// 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