Advertisement
Guest User

vShader.glsl

a guest
May 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 150
  2.  
  3. in vec4 vPosition;
  4. in vec3 vNormal;
  5. in vec2 vTexCoord;
  6.  
  7. out vec3 fL1, fL2;
  8. out vec3 fE;
  9. out vec3 fN;
  10. out vec2 texCoord;
  11.  
  12. uniform mat4 ModelView;
  13. uniform mat4 Projection;
  14. uniform vec4 LightPosition1, LightPosition2;
  15.  
  16. void main() {
  17.     // Transform vertex position into eye coordinates
  18.     vec3 pos = (ModelView * vPosition).xyz;
  19.  
  20.     // The vector to the light from the vertex
  21.     fL1 = LightPosition1.xyz - pos;
  22.     fL2 = LightPosition2.xyz - pos;
  23.  
  24.     // The vector to the eye/camera from the vertex
  25.     fE = -pos;
  26.  
  27.     // Transform vertex normal into eye coordinates (assumes scaling is uniform across dimensions)
  28.     fN = (ModelView * vec4(vNormal, 0.0)).xyz;
  29.  
  30.     gl_Position = Projection * ModelView * vPosition;
  31.     texCoord = vTexCoord;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement