37 lines
811 B
GLSL
37 lines
811 B
GLSL
|
#version 330
|
||
|
|
||
|
uniform mat4 projection;
|
||
|
uniform mat4 view;
|
||
|
uniform mat4 model;
|
||
|
uniform mat4 lightspace;
|
||
|
uniform vec3 viewPos;
|
||
|
|
||
|
|
||
|
layout (location = 0) in vec3 vert;
|
||
|
layout (location = 1) in vec3 normal;
|
||
|
layout (location = 2) in vec2 vertTexCoord;
|
||
|
layout (location = 3) in float light;
|
||
|
|
||
|
out vec3 fragPosWorld;
|
||
|
out float fragPosLightspaceZ;
|
||
|
out vec2 fragTexCoord;
|
||
|
out vec3 fragNormal;
|
||
|
out float fragLight;
|
||
|
|
||
|
void main() {
|
||
|
|
||
|
fragTexCoord = vertTexCoord;
|
||
|
fragNormal = normalize(normal);
|
||
|
fragLight = light;
|
||
|
|
||
|
gl_Position = projection * view * model * vec4(vert, 1);
|
||
|
|
||
|
vec4 pos4 = model * vec4(vert, 1);
|
||
|
fragPosWorld = pos4.xyz / pos4.w;
|
||
|
vec4 fragPosLightspace = lightspace * vec4(fragPosWorld, 1.0f);
|
||
|
fragPosLightspaceZ = fragPosLightspace.z / fragPosLightspace.w *0.5f + 0.5f;
|
||
|
|
||
|
fragPosWorld -= viewPos;
|
||
|
}
|
||
|
|