]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.cpp
Refactor projection matrix handling
[libs/gl.git] / source / effects / shadowmap.cpp
index 9aee4907a1cd5eb174bfd30d32f0bbd38c32f388..123cae274bb698327c476dfa382f69e0d266487b 100644 (file)
@@ -196,7 +196,7 @@ void ShadowMap::setup_frame(Renderer &renderer)
                {
                        float distance = (sqrt(2.0f/3.0f)-sqrt(3.0f/8.0f))*2.0f;
                        float bias = depth_bias*2.0f/(distance*l.region.width);
-                       shdata.uniform(base+".bias", -1001.0f/999.0f, 1.0f-bias);
+                       shdata.uniform(base+".bias", views[l.view_index].camera.get_projection_matrix()(2, 2), 1.0f-bias);
                }
        }
 
@@ -219,7 +219,7 @@ void ShadowMap::setup_frame(Renderer &renderer)
                        v.camera.set_depth_clip(radius/1000.0f, radius);
                }
 
-               Matrix to_texcoord = Matrix().translate(Vector3(0.5f, 0.5f, 0.5f)).scale(0.5f);
+               Matrix to_texcoord = Matrix().translate(Vector3(0.5f, 0.5f, 0.0f)).scale(Vector3(0.5f, 0.5f, 1.0f));
                shadow_matrices.push_back(to_texcoord*v.camera.get_projection_matrix()*v.camera.get_view_matrix());
        }