32 #include <osg/Referenced>
34 #include <osg/ref_ptr>
48 class GraphicsContext;
58 class CompositeViewer;
61 namespace osgCloudyDay
69 int transmittanceWidth;
70 int transmittanceHeight;
80 int transmittanceIntegralSamples;
81 int inscatterIntegralSamples;
82 int irradianceIntegralSamples;
83 int inscatterSphericalIntegralSamples;
89 float avgGroundReflectance;
108 t_preTexCfg &getTextureConfig()
115 typedef std::map<GLint, osg::Texture2D*> t_tex2DsByUnit;
116 typedef std::map<GLint, osg::Texture3D*> t_tex3DsByUnit;
118 typedef std::vector<osg::Uniform*> t_uniforms;
122 AtmospherePrecompute();
123 virtual ~AtmospherePrecompute();
125 osg::Texture2D *getTransmittanceTexture();
126 osg::Texture2D *getIrradianceTexture();
127 osg::Texture3D *getInscatterTexture();
129 const bool compute(
const bool ifDirtyOnly =
true);
132 const float defaultAltitude();
133 osg::Uniform *cmnUniform();
135 void substituteMacros(std::string &source);
139 osg::Texture2D *getDeltaETexture();
140 osg::Texture3D *getDeltaSRTexture();
141 osg::Texture3D *getDeltaSMTexture();
142 osg::Texture3D *getDeltaJTexture();
144 osg::GraphicsContext *setupContext();
146 osg::Geode *genQuad()
const;
148 osg::Texture2D *setupTexture2D(
150 ,
const GLenum internalFormat
151 ,
const GLenum pixelFormat
152 ,
const GLenum dataType
155 , osg::Image *image = NULL);
157 osg::Texture3D *setupTexture3D(
159 ,
const GLenum internalFormat
160 ,
const GLenum pixelFormat
161 ,
const GLenum dataType
165 , osg::Image *image = NULL);
167 osg::Image *getLayerFrom3DImage(
171 void setupLayerUniforms(
172 osg::StateSet *stateSet
176 osg::Program *setupProgram(
177 const std::string &fragmentShaderSource);
179 osg::Camera *setupCamera(
180 const int viewportWidth
181 ,
const int viewportHeight
183 ,
const int orderNum);
186 osg::Group *setupGroup(
187 osgViewer::CompositeViewer *viewer);
190 osgViewer::CompositeViewer *viewer);
193 osg::StateSet *stateSet
194 , t_uniforms &uniforms);
197 osg::StateSet *stateSet
198 , t_tex2DsByUnit &samplers2D
199 , t_tex3DsByUnit &samplers3D);
201 void dirtyTargets(t_tex2DsByUnit &targets2D);
202 void dirtyTargets(t_tex3DsByUnit &targets3D);
205 osgViewer::CompositeViewer *viewer
207 , t_tex2DsByUnit &targets2D
208 , t_tex2DsByUnit &samplers2D
209 , t_tex3DsByUnit &samplers3D
210 , t_uniforms &uniforms
211 ,
const char* fragmentShaderSource);
214 osgViewer::CompositeViewer *viewer
216 , t_tex3DsByUnit &targets3D
217 , t_tex2DsByUnit &samplers2D
218 , t_tex3DsByUnit &samplers3D
219 , t_uniforms &uniforms
220 ,
const char* fragmentShaderSource);
226 t_preTexCfg m_preTexCfg;
227 t_modelCfg m_modelCfg;
229 osg::ref_ptr<osg::Texture2D> m_transmittanceTexture;
230 osg::ref_ptr<osg::Texture2D> m_deltaETexture;
231 osg::ref_ptr<osg::Texture3D> m_deltaSRTexture;
232 osg::ref_ptr<osg::Texture3D> m_deltaSMTexture;
233 osg::ref_ptr<osg::Texture2D> m_irradianceTexture;
234 osg::ref_ptr<osg::Texture3D> m_inscatterTexture;
235 osg::ref_ptr<osg::Texture3D> m_deltaJTexture;
237 osg::ref_ptr<osg::Image> m_transmittanceImage;
238 osg::ref_ptr<osg::Image> m_irradianceImage;
239 osg::ref_ptr<osg::Image> m_inscatterImage;