X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Frenderpass.cpp;fp=source%2Fmaterials%2Frenderpass.cpp;h=35692a4eaa69d49e54666e5684ff46b04f03c324;hp=951cbb5d1557e5f16aad121b8bef7d10e4a78c46;hb=cb7db94f7837e6a3be037d07575dc248177d9426;hpb=04005f74fece3c33848ed9420dc0f9c431a9f0ec diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 951cbb5d..35692a4e 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -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 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::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);