Advertisement
Guest User

Untitled

a guest
May 3rd, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. #version 420
  2. // Input vertex data, different for all executions of this shader.
  3. layout(location = 0) in vec3 vertexPosition_modelspace;
  4. layout(location = 1) in vec2 textureCoords;
  5. layout(location = 2) in vec3 vertexNormal;
  6. layout(location = 3) in vec3 vertexTangent;
  7. layout(location = 4) in vec3 vertexBitangent;
  8.  
  9. struct light {
  10.     vec4 position;
  11.     vec3 diffuse;
  12.     vec3 specular;
  13.     vec3 ambient;
  14.     float attenuation;
  15. };
  16.  
  17. uniform light[5] lights;
  18.  
  19. uniform mat4 vertexPosition;
  20. uniform mat4 vertexScale;
  21. uniform mat4 vertexRotation;
  22. uniform mat4 mvp;
  23. uniform mat4 modelViewMatrix;
  24. uniform mat4 depthMVP;
  25. uniform mat3 normalMatrix;
  26. uniform mat3 modelView3xMatrix;
  27.  
  28. out vec3 Normal;
  29. out vec2 UV;
  30. out vec3 Position;
  31. out vec3 WorldPosition;
  32. out vec4 ShadowCoordinates;
  33.  
  34. out vec3 LightDir;
  35. out vec3 ViewDir;
  36.  
  37. void main() {
  38.  
  39.     UV = textureCoords;
  40.     Normal = normalize(normalMatrix * vertexNormal);
  41.     Position = vec3(modelViewMatrix * vec4(vertexPosition_modelspace,1.0));
  42.  
  43.     ShadowCoordinates = depthMVP * vec4(vertexPosition_modelspace,1.0);
  44.  
  45.     vec3 norm = normalize(normalMatrix * vertexNormal);
  46.     vec3 tang = normalize(normalMatrix * vertexTangent);
  47.     vec3 binormal = normalize(normalMatrix * vertexBitangent);
  48.  
  49.     // Matrix for transformation to tangent space
  50.     mat3 toObjectLocal = mat3(
  51.         tang.x, binormal.x, norm.x,
  52.         tang.y, binormal.y, norm.y,
  53.         tang.z, binormal.z, norm.z ) ;
  54.  
  55.     // Transform light dir. and view dir. to tangent space
  56.     LightDir = toObjectLocal * (lights[0].position.xyz - Position);
  57.     ViewDir = toObjectLocal * -Position;
  58.  
  59.     gl_Position = mvp * vec4(vertexPosition_modelspace,1.0);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement