]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/sky.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / effects / sky.h
index eb4f618d9607569bcdb32a9151a44ebf7442d8bd..cb8403e77709ff0eb8ab81e9f306c3a4fa422e2b 100644 (file)
@@ -2,21 +2,25 @@
 #define MSP_GL_SKY_H_
 
 #include "effect.h"
-#include "framebuffer.h"
 #include "programdata.h"
-#include "texture2d.h"
+#include "rendertarget.h"
 
 namespace Msp {
 namespace GL {
 
+class DirectionalLight;
 class Mesh;
-class Light;
 class Program;
 
 /**
-Renders a procedurally generated sky at the background.  Based on the paper
-"A Scalable and Production Ready Sky and Atmosphere Rendering Technique" by
-Sébastien Hillaire (https://sebh.github.io/publications/egsr2020.pdf).
+Renders a procedurally generated sky at the background.
+
+In addition to the background, the transmittance of the sun light is calculated
+to produce realistic lighting at dawn and dusk.
+
+Based on the techniques described in "A Scalable and Production Ready Sky and
+Atmosphere Rendering Technique" by Sébastien Hillaire
+(https://sebh.github.io/publications/egsr2020.pdf).
 */
 class Sky: public Effect
 {
@@ -40,31 +44,54 @@ public:
                static Planet earth();
        };
 
+       struct Template: Effect::Template
+       {
+               class Loader: public DataFile::DerivedObjectLoader<Template, Effect::Template::Loader>
+               {
+               private:
+                       static ActionMap shared_actions;
+
+               public:
+                       Loader(Template &, Collection &);
+               private:
+                       virtual void init_actions();
+               };
+
+               DirectionalLight *sun = 0;
+
+               virtual Sky *create(const std::map<std::string, Renderable *> &) const;
+       };
+
 private:
-       const Light &sun;
-       Texture2D transmittance_lookup;
+       Planet planet;
+       DirectionalLight &sun;
+       RenderTarget transmittance_lookup;
        const Program &transmittance_shprog;
-       Framebuffer transmittance_fbo;
        bool transmittance_lookup_dirty;
-       Texture2D distant;
+       RenderTarget distant;
        const Program &distant_shprog;
-       Framebuffer distant_fbo;
        const Mesh &fullscreen_mesh;
        const Program &backdrop_shprog;
        const Sampler &sampler;
        const Sampler &wrap_sampler;
+       const Texture &dummy_texture;
        mutable ProgramData shdata;
+       float view_height;
        bool rendered;
 
 public:
-       Sky(Resources &, Renderable &, const Light &);
+       Sky(Renderable &, DirectionalLight &);
 
        void set_planet(const Planet &);
        void set_view_height(float);
 
+       Color get_transmittance(const Vector3 &);
+
        virtual void setup_frame(Renderer &);
        virtual void finish_frame();
        virtual void render(Renderer &, Tag = Tag()) const;
+
+       virtual void set_debug_name(const std::string &);
 };
 
 } // namespace GL