]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/environmentmap.cpp
Support effects and subordinate sequences inside sequence templates
[libs/gl.git] / source / effects / environmentmap.cpp
index 6fb0e5c3b314656dca8361dc9b54544969c98c68..419f402b8d22287c89bfb89549190ed6a5ae8b07 100644 (file)
@@ -2,6 +2,7 @@
 #include <cmath>
 #include <msp/strings/format.h>
 #include "environmentmap.h"
+#include "error.h"
 #include "mesh.h"
 #include "renderer.h"
 #include "resources.h"
@@ -165,7 +166,7 @@ void EnvironmentMap::finish_frame()
 
 void EnvironmentMap::render(Renderer &renderer, Tag tag) const
 {
-       if(!enabled_passes.count(tag))
+       if(!enabled_methods.count(tag))
                return renderer.render(renderable, tag);
 
        Renderer::Push _push_rend(renderer);
@@ -179,7 +180,7 @@ void EnvironmentMap::render(Renderer &renderer, Tag tag) const
 void EnvironmentMap::set_debug_name(const string &name)
 {
 #ifdef DEBUG
-       env_tex.set_debug_name(name+"/environment.texcb");
+       env_tex.set_debug_name(name+"/environment.tex");
        depth_buf.set_debug_name(name+"/environment_depth.rbuf");
        static const char *const face_names[] = { "X+", "X-", "Y+", "Y-", "Z+", "Z-" };
        for(unsigned i=0; i<6; ++i)
@@ -188,7 +189,7 @@ void EnvironmentMap::set_debug_name(const string &name)
                faces[i].camera.set_debug_name(format("%s/%s.camera", name, face_names[i]));
        }
 
-       irradiance.set_debug_name(name+"/irradiance.texcb");
+       irradiance.set_debug_name(name+"/irradiance.tex");
        irradiance_fbo.set_debug_name(name+" [FBO:irradiance]");
        for(unsigned i=0; i<specular_fbos.size(); ++i)
                specular_fbos[i].set_debug_name(format("%s [FBO:specular_mip%d]", name, i+1));
@@ -199,5 +200,47 @@ void EnvironmentMap::set_debug_name(const string &name)
 #endif
 }
 
+
+EnvironmentMap *EnvironmentMap::Template::create(const map<string, Renderable *> &renderables) const
+{
+       Renderable *content = get_item(renderables, content_name);
+       Renderable *environment = get_item(renderables, environment_name);
+       if(!content || !environment)
+               throw invalid_operation("EnvironmentMap::Template::create");
+
+       RefPtr<EnvironmentMap> env_map = new EnvironmentMap(size, format, roughness_levels, *content, *environment);
+       if(use_fixed_position)
+               env_map->set_fixed_position(fixed_position);
+       env_map->set_depth_clip(near_clip, far_clip);
+
+       return env_map.release();
+}
+
+
+DataFile::Loader::ActionMap EnvironmentMap::Template::Loader::shared_actions;
+
+EnvironmentMap::Template::Loader::Loader(Template &t, Collection &c):
+       DerivedObjectLoader<Template, Effect::Template::Loader>(t, c)
+{
+       set_actions(shared_actions);
+}
+
+void EnvironmentMap::Template::Loader::init_actions()
+{
+       Effect::Template::Loader::init_actions();
+       add("depth_clip", &Template::near_clip, &Template::far_clip);
+       add("environment", &Template::environment_name);
+       add("fixed_position", &Loader::fixed_position);
+       add("format", &Template::format);
+       add("roughness_levels", &Template::roughness_levels);
+       add("size", &Template::size);
+}
+
+void EnvironmentMap::Template::Loader::fixed_position(float x, float y, float z)
+{
+       obj.fixed_position = Vector3(x, y, z);
+       obj.use_fixed_position = true;
+}
+
 } // namespace GL
 } // namespace Msp