Want more features on Pastebin? Sign Up, it's FREE!
Guest

Reflection shader - Vertex Shader

By: a guest on Jun 16th, 2012  |  syntax: OpenGL Shading  |  size: 1.17 KB  |  views: 196  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #version 150
  2. #define GL_core_profile 1
  3. #extension GL_EXT_gpu_shader4 : enable
  4. #extension GL_ARB_shader_texture_lod : enable
  5.  
  6. uniform mat4 Gpu_ModelViewMatrix;                                       // Modelview
  7. uniform mat4 Gpu_ModelViewMatrixInverse;        // Inverse of modelview
  8. uniform mat4 Gpu_ProjectionMatrix;                              // Projection
  9. uniform mat3 Gpu_NormalMatrix;                                          // Normal matrix (IT of 3x3 rotation part of modelview)
  10. uniform vec3 lightPos;                                                                          // Light position
  11.  
  12. in vec3 Gpu_Vertex;                                     // Vertices (attr 0)
  13. in vec3 Gpu_Normal;                                     // Normals (attr 3)
  14. in vec4 Gpu_MultiTexCoord0;     // TexCoords (attr 1 and 2)
  15. in vec4 Gpu_MultiTexCoord1;
  16.  
  17. out vec3 vert_vout;                                     // Vertices in view space
  18. out vec3 normal_vout;                           // Normals in view space
  19. out vec3 light_vout;                            // Light in view space
  20. out vec4 projCoord_vout;                // Projection coordinates (projective texcoords between -1 - 1 from camera)
  21.  
  22. void main()
  23. {
  24.         vert_vout = vec3(Gpu_ModelViewMatrix * vec4(Gpu_Vertex, 1.0));
  25.         light_vout = vec3(Gpu_ModelViewMatrixInverse * vec4(lightPos, 1.0));
  26.         normal_vout = Gpu_NormalMatrix * Gpu_Normal;
  27.         projCoord_vout = Gpu_ProjectionMatrix * Gpu_ModelViewMatrix * vec4(Gpu_Vertex, 1.0);
  28.  
  29.         gl_Position = projCoord_vout;
  30. }
clone this paste RAW Paste Data