4 #include "SkydomeMie.h"
5 #include "SkydomeHimmel.h"
10 #include <osg/MatrixTransform>
12 #include <osg/Geometry>
13 #include <osg/Program>
15 #include <osg/Texture2D>
17 #include <osg/BlendFunc>
18 #include <osg/CullFace>
19 #include <osgDB/ReadFile>
20 #include <osg/NodeVisitor>
21 #include <osg/Texture2D>
22 #include <osgDB/ReadFile>
23 #include <osgViewer/Renderer>
25 #include <osg/Texture2D>
26 #include <osg/Texture3D>
29 #define SHADOW_MAPPING
31 namespace osgCloudyDay
44 Scene(
int width,
int height);
179 static osg::FrameBufferObject* fbo_vert_linear_blur2;
180 static osg::FrameBufferObject* fbo_hori_linear_blur2;
181 static osg::FrameBufferObject* fbo_scene_viewer;
184 static osg::ref_ptr<osg::Texture2D> fbo_light_texture2;
185 static osg::ref_ptr<osg::Texture2D> fbo_goodrays;
186 static osg::ref_ptr<osg::Texture2D> fbo_scene_depth;
187 static osg::ref_ptr<osg::Texture2D> fbo_scene_texture;
188 static osg::ref_ptr<osg::Texture2D> fbo_hud_texture;
189 static osg::ref_ptr<osg::Texture2D> fbo_blur_texture;
190 static osg::ref_ptr<osg::Texture2D> fbo_light_depth;
195 static osg::ref_ptr<osg::Program> shadowProg;
196 static osg::ref_ptr<osg::Program> lightningProg;
197 static osg::ref_ptr<osg::Program> debugProg;
199 static osg::ref_ptr<osg::Camera> m_ViewCameraDepthOnly;
200 static osg::ref_ptr<osg::Camera> m_ViewCamera;
201 static osg::ref_ptr<osg::Camera> m_LightCamera;
202 static osg::ref_ptr<osg::Camera> m_ViewDepthCamera;
213 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
234 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
260 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
263 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
277 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
280 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
293 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
307 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
322 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
324 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
325 osg::ref_ptr<osg::Geode> geometry =
dynamic_cast<osg::Geode*
> (node);
330 osg::Vec3f eye = osg::Vec3f();
331 osg::Vec3f center = osg::Vec3f();
332 osg::Vec3f up = osg::Vec3f();
339 osg::Matrixd view(cv->getCurrentCamera()->getViewMatrix());
340 osg::Matrixd invViewMatrix = osg::Matrixd::inverse(view);
341 osg::Matrixd modelview(*cv->getModelViewMatrix());
342 osg::Matrixd model = modelview*invViewMatrix;
343 osg::Matrixd proj(cv->getCurrentCamera()->getProjectionMatrix());
345 geometry->getOrCreateStateSet()->getUniform(
"ModelMatrix")->set(model);
349 #ifdef SHADOW_MAPPING
351 geometry->getOrCreateStateSet()->getUniform(
"light_mv_matrix")->set(
Scene::GetLightCamera()->getViewMatrix());
366 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
368 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
369 osg::ref_ptr<osg::Geode> geometry =
dynamic_cast<osg::Geode*
> (node);
373 osg::Matrixd view(cv->getCurrentCamera()->getViewMatrix());
374 osg::Matrixd invViewMatrix = osg::Matrixd::inverse(view);
375 osg::Matrixd modelview(*cv->getModelViewMatrix());
376 osg::Matrixd model = modelview*invViewMatrix;
377 osg::Matrixd proj(cv->getCurrentCamera()->getProjectionMatrix());
379 geometry->getOrCreateStateSet()->getUniform(
"ModelMatrix")->set(model);
414 #ifdef SHADOW_MAPPING
416 geometry->getOrCreateStateSet()->getUniform(
"light_mv_matrix")->set(
Scene::GetLightCamera()->getViewMatrix());