Added basic shadows to point lights; Better than directional shadows

This commit is contained in:
grayson committed 2021-09-13 23:45:42 -05:00
1 parent 4b14362a04
commit 1a8320feab
21 files changed
+250 -71

No files matched your search

@@ -0,0 +1,12 @@
#version 330 core
in vec4 fragPos;
uniform vec3 lightPos;
uniform float farPlane;
void main() {
float dist = length(fragPos.xyz - lightPos);
dist /= farPlane;
gl_FragDepth = dist;
}
@@ -0,0 +1,20 @@
#version 330 core
layout(triangles) in;
layout(triangle_strip, max_vertices = 18) out;
uniform mat4 lightSpaceMat[6];
out vec4 fragPos;
void main() {
for (int face = 0; face < 6; face++) {
gl_Layer = face;
for (int i = 0; i < 3; i++) {
fragPos = gl_in[i].gl_Position;
gl_Position = lightSpaceMat[face] * fragPos;
EmitVertex();
}
EndPrimitive();
}
}
@@ -0,0 +1,9 @@
#version 330 core
layout(location = 0) in vec3 pos;
uniform mat4 model;
void main() {
gl_Position = model * vec4(pos, 1.0);
}