Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330 core
- layout(location = 0) in vec3 position;
- layout(location = 1) in vec3 normal;
- uniform vec3 lightPositions[8];
- uniform mat4 modelMatrix;
- uniform mat4 viewMatrix;
- uniform mat4 projectionMatrix;
- uniform mat4 lightMatrix;
- out vec3 surfaceNormal;
- out vec3 toLight[8];
- out vec3 toCamera;
- void main(void){
- vec4 vertex = vec4(position, 1.0);
- vec4 vertexNormal = vec4(normal, 0.0);
- //Vertexberechnung
- vec4 worldPosition = modelMatrix * vertex;
- gl_Position = projectionMatrix * viewMatrix * worldPosition;
- mat4 normalMatrix = transpose(inverse(viewMatrix * modelMatrix));
- surfaceNormal = (normalMatrix * vertexNormal).xyz;
- vec4 vertexPosition = (viewMatrix * modelMatrix * vertex);
- toCamera = (vertexPosition * -1).xyz;
- //Berechnung der Vectoren zu den Lichtquellen
- for(int i = 0; i < 8; i++){
- vec4 lightPos = vec4(lightPositions[i], 1.0);
- toLight[i] = ((viewMatrix * lightPos) - vertexPosition).xyz;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement