VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgLightingComponent.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
15 #include <osg/Uniform>
16 #include <vector>
17 
19 
20 namespace osg
21 {
22  class Matrixd;
23 }
24 
25 namespace makVrv
26 {
27  class DtLight;
28  class DtLightData;
29  class DtTileSpaceLightGrid;
30  class DtGLTexture;
31  class DtGLTextureBufferObject;
32  class DeDe;
33 
34  class TextureApplyAttribute;
35  class TextureBufferObjectApplyAttribute;
36 
42  {
43  public:
45  DtOsgLightingComponent(int maxLights, DtDe& de);
46 
48  virtual ~DtOsgLightingComponent();
49 
51  void update(const VectorLights& lights, const osg::State& state);
52 
54  void setMaxLights(int maxNumLights);
55 
56  static int getTextureStartOffset(void);
57 
58  const Vector2_uint32& GetTileSize(void) const;
59  const Vector2_uint32& GetGridMaxDims(void) const;
60 
61  public: // Access to internal uniforms
62 
64  osg::Uniform* getEnableLightingUniform() const;
65 
67  void setAmbientFactor(float ambientFactor);
68 
70  void setUseGlobalAmbient(bool useGlobalAmbient);
71 
73  void setDiffuseFactor(float diffuseFactor);
74 
76  void setUseGlobalDiffuse(bool useGlobalDiffuse);
77 
79  void setUseHDR(bool useHDR);
80 
82  void setDirty(bool isDirty) { myDirty = isDirty; }
83 
85  void setEmissionFactor(float emissionFactor);
86 
88  bool dirty() const { return myDirty; }
89 
90  void releaseGLObjects(void);
91 
92  public: // DtOsgStateComponent interface
93 
95  virtual bool install(osg::StateSet* stateset);
96 
98  virtual bool uninstall(osg::StateSet* stateset);
99 
100  protected:
101 
102  void setLightPointScale(double scale);
103  void setDynamicLightScale(double scale);
104  void setEmissiveTextureScale(double scale);
105  void setSpecularScale(double scale);
106  void setShininessScale(double scale);
107 
108  void setHdrOutputScale(double scale);
109 
110  osg::Uniform* createUniform(const std::string& name, osg::Uniform::Type type, int count=1);
111 
112  void PackLights(const VectorLights& lights
113  , const osg::State& state);
114  void UpdateTextureLightDataGrid(void);
115  void UpdateTiledShadingData(const VectorLights& lights
116  , const osg::State& state);
117 
118  void UpdateTileLightIndexListTexture();
119  void UpdateTileLightGridCountOffsetsTexture();
120 
121  protected:
122 
123  osg::ref_ptr<osg::Uniform> myEnableLightingUniform;
124 
125  std::vector<osg::Uniform*> myUniforms;
126 
127  // Parameters of lights are stored in this structure
129 
131  osg::ref_ptr<osg::Uniform> myLightTextureUniform;
132 
134 
136  osg::ref_ptr<osg::Uniform> myTileLightIndexListTextureUniform;
137 
139  osg::ref_ptr<osg::Uniform> myTileLightGridCountOffsetsTextureUniform;
140 
142  osg::ref_ptr<osg::Uniform> myColorRampTextureUniform;
143 
144  osg::ref_ptr<TextureApplyAttribute> myTextureApplyAttribute;
145  osg::ref_ptr<TextureBufferObjectApplyAttribute> myTextureBufferObjectApplyAttribute;
146 
147  osg::ref_ptr<osg::Uniform> myProjectionMatrixUniform;
148  osg::ref_ptr<osg::Uniform> myViewportSizeUniform;
149 
150  osg::ref_ptr<osg::Uniform> myLightGridTileDimUniform;
151  osg::ref_ptr<osg::Uniform> myLightGridMaxDimUniform;
152 
153  osg::ref_ptr<osg::Uniform> myAmbientFactorUniform;
155  osg::ref_ptr<osg::Uniform> myDiffuseFactorUniform;
157  bool myUseHDR;
158  bool myDirty;
159  osg::ref_ptr<osg::Uniform> myEmissionFactorUniform;
160 
161  osg::ref_ptr<osg::Uniform> myTransmittanceFactorUniform;
162  osg::ref_ptr<osg::Uniform> myModelTransmittanceUniform;
163 
164  osg::ref_ptr<osg::Uniform> myLightPointScaleUniform;
165  osg::ref_ptr<osg::Uniform> myDynamicLightScaleUniform;
166  osg::ref_ptr<osg::Uniform> myEmissiveTextureScaleUniform;
167  osg::ref_ptr<osg::Uniform> mySpecularScaleUniform;
168  osg::ref_ptr<osg::Uniform> myShininessScaleUniform;
169 
170  osg::ref_ptr<osg::Uniform> myHdrOutputScaleUniform;
171 
173 
176 
178 
181 
182  };
183 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)