physical_vertex.glsl 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Physical maiterial vertex shader
  3. //
  4. #include <attributes>
  5. // Model uniforms
  6. uniform mat4 ModelViewMatrix;
  7. uniform mat3 NormalMatrix;
  8. uniform mat4 MVP;
  9. // Output variables for Fragment shader
  10. out vec4 Position;
  11. out vec3 Normal;
  12. out vec3 CamDir;
  13. out vec2 FragTexcoord;
  14. void main() {
  15. // Transform this vertex position to camera coordinates.
  16. Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
  17. // Transform this vertex normal to camera coordinates.
  18. Normal = normalize(NormalMatrix * VertexNormal);
  19. // Calculate the direction vector from the vertex to the camera
  20. // The camera is at 0,0,0
  21. CamDir = normalize(-Position.xyz);
  22. // // Flips texture coordinate Y if requested.
  23. vec2 texcoord = VertexTexcoord;
  24. //#if MAT_TEXTURES>0
  25. // if (MatTexFlipY(0)) {
  26. // texcoord.y = 1 - texcoord.y;
  27. // }
  28. //#endif
  29. FragTexcoord = texcoord;
  30. gl_Position = MVP * vec4(VertexPosition, 1.0);
  31. }