Some bugfixes for the shadows
They work well now!
This commit is contained in:
parent
3c35a730f5
commit
88611815e1
@ -117,6 +117,6 @@ void main() {
|
||||
float shadow = get_shadow(fs_in.FragPosLightSpace, normal);
|
||||
|
||||
// Apply
|
||||
FragColor = vec4(ambient + albedo + specular - shadow * 4.0, 1.0);
|
||||
FragColor = vec4(ambient + albedo + specular - shadow * 0.25, 1.0);
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ class DirectionalLight {
|
||||
glm::mat4 get_light_space_matrix() {
|
||||
// TODO: Make the values here configurable
|
||||
float near_plane = 1.0f, far_plane = 100.0f;
|
||||
glm::mat4 lightProjection = glm::ortho(-40.0f, 40.0f, -40.0f, 40.0f, near_plane, far_plane);
|
||||
glm::mat4 lightView = glm::lookAt(-direction * 40.0f, direction, glm::vec3(0.0, 1.0, 0.0));
|
||||
glm::mat4 lightProjection = glm::ortho(-20.0f, 20.0f, -20.0f, 20.0f, near_plane, far_plane);
|
||||
glm::mat4 lightView = glm::lookAt(-direction * 10.0f, direction, glm::vec3(0.0, 1.0, 0.0));
|
||||
return lightProjection * lightView;
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ class DirectionalLight {
|
||||
unsigned int depth_map;
|
||||
unsigned int depth_map_fbo;
|
||||
|
||||
const unsigned int SHADOW_WIDTH = 1024;
|
||||
const unsigned int SHADOW_HEIGHT = 1024;
|
||||
const unsigned int SHADOW_WIDTH = 4096;
|
||||
const unsigned int SHADOW_HEIGHT = 4096;
|
||||
|
||||
Gedeng::Shader shadow_shader;
|
||||
};
|
||||
|
@ -90,6 +90,7 @@ class ShadowApp : public Gedeng::Application {
|
||||
light.render_shadow(monkey_mesh);
|
||||
light.render_shadow(quad_mesh);
|
||||
|
||||
glViewport(0, 0, 1920, 1080);
|
||||
glClearColor(0.1, 0.1f, 0.1, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user