Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 0.96 KB | None | 0 0
  1. #version 330 core
  2.  
  3. layout(location = 0) in vec3 position;
  4. layout(location = 1) in vec3 normal;
  5.  
  6. uniform vec3 lightPositions[8];
  7.  
  8. uniform mat4 modelMatrix;
  9. uniform mat4 viewMatrix;
  10. uniform mat4 projectionMatrix;
  11.  
  12. uniform mat4 lightMatrix;
  13.  
  14. out vec3 surfaceNormal;
  15. out vec3 toLight[8];
  16. out vec3 toCamera;
  17.  
  18. void main(void){
  19.  
  20.     vec4 vertex = vec4(position, 1.0);
  21.     vec4 vertexNormal = vec4(normal, 0.0);
  22.  
  23.     //Vertexberechnung
  24.     vec4 worldPosition = modelMatrix * vertex;
  25.     gl_Position = projectionMatrix * viewMatrix  * worldPosition;
  26.    
  27.     mat4 normalMatrix = transpose(inverse(viewMatrix * modelMatrix));
  28.     surfaceNormal = (normalMatrix * vertexNormal).xyz;
  29.    
  30.     vec4 vertexPosition = (viewMatrix * modelMatrix * vertex);
  31.     toCamera = (vertexPosition * -1).xyz;
  32.    
  33.     //Berechnung der Vectoren zu den Lichtquellen      
  34.     for(int i = 0; i < 8; i++){
  35.         vec4 lightPos = vec4(lightPositions[i], 1.0);
  36.         toLight[i] = ((viewMatrix * lightPos) - vertexPosition).xyz;
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement