Created
March 10, 2013 00:36
-
-
Save finlaybob/5126529 to your computer and use it in GitHub Desktop.
Normal Map Vertex Shader
This file contains hidden or 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
#version 400 | |
layout (location = 0) in vec3 attribPosition; | |
layout (location = 1) in vec3 attribNormal; | |
layout (location = 2) in vec2 attribTexCoord; | |
layout (location = 3) in vec3 attribTangent; | |
layout (location = 3) in vec3 attribBinormal; | |
uniform mat4 mvp; | |
uniform mat4 mvm; | |
uniform mat3 nm; | |
uniform vec3 lightPos_World; | |
out vec2 vUvs; | |
out vec3 lightPos_Eye; | |
out vec3 vertexPos_Eye; | |
out vec3 normalDir_Eye; | |
out vec3 normalDir_World; | |
out mat3 tbnMatrix; | |
void main() | |
{ | |
vUvs = attribTexCoord; | |
normalDir_World = attribNormal; | |
normalDir_Eye = (nm * attribNormal); | |
vec3 t = nm * attribTangent; | |
vec3 n = nm * attribNormal; | |
vec3 b = nm * cross(n,t); | |
mat3 tbnMatrix = mat3(t.x, b.x, n.x, | |
t.y, b.y, n.y, | |
t.z, b.z, n.z); | |
vertexPos_Eye = (mvm * vec4(attribPosition,1.0)).xyz; | |
lightPos_Eye = (mvm * vec4(lightPos_World,1.0)).xyz; | |
gl_Position = mvp * vec4(attribPosition,1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment