]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/renderpass.cpp
Move the receive_shadows flag to RenderPass
[libs/gl.git] / source / materials / renderpass.cpp
index 951cbb5d1557e5f16aad121b8bef7d10e4a78c46..35692a4eaa69d49e54666e5684ff46b04f03c324 100644 (file)
@@ -22,7 +22,8 @@ RenderPass::RenderPass():
        shprog_from_material(false),
        shdata(0),
        material(0),
-       back_faces(false)
+       back_faces(false),
+       receive_shadows(false)
 { }
 
 void RenderPass::set_material_textures()
@@ -37,9 +38,13 @@ void RenderPass::maybe_create_material_shader(DataFile::Collection *coll)
        if(shprog && !shprog_from_material)
                return;
 
+       map<string, int> extra_spec;
+       if(receive_shadows)
+               extra_spec["use_shadow_map"] = true;
+
        if(coll)
        {
-               shprog = material->create_compatible_shader(*coll);
+               shprog = material->create_compatible_shader(*coll, extra_spec);
                shprog.keep();
        }
        else
@@ -125,6 +130,11 @@ int RenderPass::get_texture_index(const string &n) const
        return (shprog && i!=textures.end() ? shprog->get_uniform_binding(i->tag) : -1);
 }
 
+void RenderPass::set_receive_shadows(bool rs)
+{
+       receive_shadows = rs;
+}
+
 void RenderPass::apply(Renderer &renderer) const
 {
        for(vector<TextureSlot>::const_iterator i=textures.begin(); i!=textures.end(); ++i)
@@ -156,6 +166,7 @@ void RenderPass::Loader::init_actions()
        add("material", &Loader::material);
        add("material_slot", &RenderPass::material_slot);
        add("back_faces",&RenderPass::back_faces);
+       add("receive_shadows", &RenderPass::receive_shadows);
        add("texture", &Loader::texture);
        add("uniforms", &Loader::uniforms);
        add("uniform_slot", &Loader::uniform_slot);