CloudyDay
 All Classes Functions Variables Enumerations
CloudGeometry.h
1 #pragma once
2 #include "Scene.h"
3 
4 #include <osg/Geometry>
5 #include <osg/State>
6 #include <osg/ArrayDispatchers>
7 #include <osg/PrimitiveSet>
8 #include <osg/Shader>
9 #include <osg/Program>
10 
11 #include <osg/ClearNode>
12 #include <osgViewer/Viewer>
13 #include <osg/GL>
14 #include <osgUtil/RenderStage>
15 #include <osg/PolygonOffset>
16 #include <osg/BlendFunc>
17 #include <osg/BlendEquation>
18 #include <osg/Depth>
19 
20 #include <iostream>
21 #include <algorithm>
22 
23 #define SHADOW_MAPPING
24 namespace osgCloudyDay
25 {
29  class CloudGeometry : public osg::Geometry
30  {
31  public:
36  CloudGeometry( osg::ref_ptr<osg::Texture2D> _tex_clouds,
37  osg::ref_ptr<osg::Texture2D> _fbo_light_texture,
38  osg::ref_ptr<osg::Texture2D> _fbo_light_depth,
39  osg::ref_ptr<osg::Texture2D> _fbo_blur_texture,
40  osg::ref_ptr<osg::FrameBufferObject> _fbo_shadow,
41  osg::ref_ptr<osg::FrameBufferObject> _fbo_vert_linear_blur,
42  osg::ref_ptr<osg::FrameBufferObject> _fbo_hori_linear_blur,
43  osg::ref_ptr<osg::FrameBufferObject> _fbo_hori_blur,
44  osg::ref_ptr<osg::FrameBufferObject> _fbo_vert_blur,
45  osg::ref_ptr<osg::FrameBufferObject> _fbo_cloud_viewer,
46  osg::ref_ptr<osg::FrameBufferObject> _fbo_hori_blur2,
47  osg::ref_ptr<osg::Program> viewer,
48  osg::ref_ptr<osg::Program> light,
49  osg::ref_ptr<osg::Program> blur_vert,
50  osg::ref_ptr<osg::Program> blur_hori,
51  osg::ref_ptr<osg::Program> blur_linear_vert,
52  osg::ref_ptr<osg::Program> blur_linear_hori,
53  osg::ref_ptr<osg::Program> shadow_map);
54  ~CloudGeometry(void);
55 
56  void AddLayer(int type);
57  void AddPrimitive(int type);
58  void SetActiveLayer(int layer);
59  void DeletePrimitives();
60 
61  osg::ref_ptr<osg::FrameBufferObject> fbo_cloud_viewer;
62 
63  osg::ref_ptr<osg::Program> sh_viewer;
64  osg::ref_ptr<osg::Program> sh_light;
65  osg::ref_ptr<osg::Program> sh_blur_vert;
66  osg::ref_ptr<osg::Program> sh_blur_hori;
67  osg::ref_ptr<osg::Program> sh_blur_linear_vert;
68  osg::ref_ptr<osg::Program> sh_blur_linear_hori;
69  osg::ref_ptr<osg::Program> sh_shadow_map;
70 
71  osg::ref_ptr<osg::Texture2D> tex_clouds;
72  osg::ref_ptr<osg::Texture2D> fbo_light_texture;
73  osg::ref_ptr<osg::Texture2D> fbo_light_depth;
74  osg::ref_ptr<osg::Texture2D> fbo_blur_texture;
75  osg::ref_ptr<osg::FrameBufferObject> fbo_shadow;
76  osg::ref_ptr<osg::FrameBufferObject> fbo_vert_linear_blur;
77  osg::ref_ptr<osg::FrameBufferObject> fbo_hori_linear_blur;
78  osg::ref_ptr<osg::FrameBufferObject> fbo_hori_blur;
79  osg::ref_ptr<osg::FrameBufferObject> fbo_vert_blur;
80  osg::ref_ptr<osg::FrameBufferObject> fbo_hori_blur2;
81 
82  osg::ref_ptr<osg::Uniform> projectuniform;
83  osg::ref_ptr<osg::Uniform> modelViewMatrixuniform;
84  osg::ref_ptr<osg::Uniform> viewMatrixuniform;
85  osg::ref_ptr<osg::Uniform> viewMatrixInvuniform;
86 
87  osg::ref_ptr<osg::Uniform> project_lightuniform;
88  osg::ref_ptr<osg::Uniform> modelViewMatrix_lightuniform;
89  osg::ref_ptr<osg::Uniform> viewMatrix_lightuniform;
90  osg::ref_ptr<osg::Uniform> viewMatrixInv_lightuniform;
91 
92  void Active(bool type);
93  bool processing;
94  std::vector<int> m_layers;
95 
96  bool m_slicingViewVectorTransformed;
97 
98  unsigned int m_active_layer;
99 
100  osg::ref_ptr<osg::UIntArray> m_primitive2Layer;
101 
102  osg::ref_ptr<osg::IntArray> m_numPrimitiveArrays;
103  osg::ref_ptr<osg::IntArray> m_CloudsIterArrays;
104 
105  virtual void CloudGeometry::drawImplementation(osg::RenderInfo& renderInfo) const;
106 
107  static bool blur;
108  };
109 }