Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 420
- // Input vertex data, different for all executions of this shader.
- layout(location = 0) in vec3 vertexPosition_modelspace;
- layout(location = 1) in vec2 textureCoords;
- layout(location = 2) in vec3 vertexNormal;
- layout(location = 3) in vec3 vertexTangent;
- layout(location = 4) in vec3 vertexBitangent;
- struct light {
- vec4 position;
- vec3 diffuse;
- vec3 specular;
- vec3 ambient;
- float attenuation;
- };
- uniform light[5] lights;
- uniform mat4 vertexPosition;
- uniform mat4 vertexScale;
- uniform mat4 vertexRotation;
- uniform mat4 mvp;
- uniform mat4 modelViewMatrix;
- uniform mat4 depthMVP;
- uniform mat3 normalMatrix;
- uniform mat3 modelView3xMatrix;
- out vec3 Normal;
- out vec2 UV;
- out vec3 Position;
- out vec3 WorldPosition;
- out vec4 ShadowCoordinates;
- out vec3 LightDir;
- out vec3 ViewDir;
- void main() {
- UV = textureCoords;
- Normal = normalize(normalMatrix * vertexNormal);
- Position = vec3(modelViewMatrix * vec4(vertexPosition_modelspace,1.0));
- ShadowCoordinates = depthMVP * vec4(vertexPosition_modelspace,1.0);
- vec3 norm = normalize(normalMatrix * vertexNormal);
- vec3 tang = normalize(normalMatrix * vertexTangent);
- vec3 binormal = normalize(normalMatrix * vertexBitangent);
- // Matrix for transformation to tangent space
- mat3 toObjectLocal = mat3(
- tang.x, binormal.x, norm.x,
- tang.y, binormal.y, norm.y,
- tang.z, binormal.z, norm.z ) ;
- // Transform light dir. and view dir. to tangent space
- LightDir = toObjectLocal * (lights[0].position.xyz - Position);
- ViewDir = toObjectLocal * -Position;
- gl_Position = mvp * vec4(vertexPosition_modelspace,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement