]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / effects / shadowmap.cpp
index 9aee4907a1cd5eb174bfd30d32f0bbd38c32f388..bbf602bc60f2ed483215074c0727eba0e8ea2634 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());
        }
 
@@ -298,6 +298,8 @@ ShadowMap *ShadowMap::Template::create(const map<string, Renderable *> &renderab
                        throw invalid_operation("ShadowMap::Template::create");
        }
 
+       create_base(*shadow_map);
+
        return shadow_map.release();
 }