VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 <osg/Texture2D>
17 
18 #include <vector>
19 
21 
22 namespace osg
23 {
24  class Matrixd;
25 }
26 
27 namespace makVrv
28 {
29  class DtLight;
30  class DtLightData;
31  class DtTileSpaceLightGrid;
32  class DtGlTexture;
33  class DtGlTextureBufferObject;
34  class DeDe;
35 
36  class TextureApplyAttribute;
37  class TextureBufferObjectApplyAttribute;
38 
44  {
45  public:
47  DtOsgLightingComponent(int maxLights, DtDe& de);
48 
50  virtual ~DtOsgLightingComponent();
51 
53  void update(const VectorLights& lights, const osg::State& state);
54 
56  void setMaxLights(int maxNumLights);
57 
58  static int getTextureStartOffset(void);
59 
60  const Vector2_uint32& GetTileSize(void) const;
61  const Vector2_uint32& GetGridMaxDims(void) const;
62 
63  public: // Access to internal uniforms
64 
66  osg::Uniform* getEnableLightingUniform() const;
67 
69  void setAmbientFactor(float ambientFactor);
70 
72  void setUseGlobalAmbient(bool useGlobalAmbient);
73 
75  void setDiffuseFactor(float diffuseFactor);
76 
78  void setUseGlobalDiffuse(bool useGlobalDiffuse);
79 
81  void setUseHDR(bool useHDR);
82 
84  void setDirty(bool isDirty) { myDirty = isDirty; }
85 
87  void setEmissionFactor(float emissionFactor);
88 
90  bool dirty() const { return myDirty; }
91 
92  void releaseGLObjects(void);
93 
94  public: // DtOsgStateComponent interface
95 
97  virtual bool install(osg::StateSet* stateset);
98 
100  virtual bool uninstall(osg::StateSet* stateset);
101 
102  protected:
103 
104  void setLightPointScale(double scale);
105  void setDynamicLightScale(double scale);
106  void setEmissiveTextureScale(double scale);
107  void setSpecularScale(double scale);
108  void setShininessScale(double scale);
109 
110  void setHdrOutputScale(double scale);
111 
112  osg::Uniform* createUniform(const std::string& name, osg::Uniform::Type type, int count=1);
113 
114  void PackLights(const osg::Matrixd &normalMatrix, const VectorLights& lights , const osg::State& state);
115  void UpdateTextureLightDataGrid(void);
116  void UpdateTiledShadingData(const VectorLights& lights, 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::ref_ptr<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> myViewportSizeUniform;
148 
149  osg::ref_ptr<osg::Uniform> myLightGridTileDimUniform;
150  osg::ref_ptr<osg::Uniform> myLightGridMaxDimUniform;
151 
152  osg::ref_ptr<osg::Uniform> myAmbientFactorUniform;
154  osg::ref_ptr<osg::Uniform> myUseGlobalAmbientUniform;
155  osg::ref_ptr<osg::Uniform> myDiffuseFactorUniform;
157  osg::ref_ptr<osg::Uniform> myUseGlobalDiffuseUniform;
158  bool myUseHDR;
159  bool myDirty;
160  osg::ref_ptr<osg::Uniform> myEmissionFactorUniform;
161 
162  osg::ref_ptr<osg::Uniform> myTransmittanceFactorUniform;
163  osg::ref_ptr<osg::Uniform> myModelTransmittanceUniform;
164 
165  osg::ref_ptr<osg::Uniform> myLightPointScaleUniform;
166  osg::ref_ptr<osg::Uniform> myDynamicLightScaleUniform;
167  osg::ref_ptr<osg::Uniform> myEmissiveTextureScaleUniform;
168  osg::ref_ptr<osg::Uniform> mySpecularScaleUniform;
169  osg::ref_ptr<osg::Uniform> myShininessScaleUniform;
170 
171  osg::ref_ptr<osg::Uniform> myHdrOutputScaleUniform;
172  osg::ref_ptr<osg::Uniform> myUpVectorUniform;
173  osg::ref_ptr<osg::Uniform> myBDRFLutUniform;
174  osg::ref_ptr<osg::Texture2D> myBDRFLutTexture;
175  osg::ref_ptr<osg::Image> myBDRFLutImage;
176 
178 
181 
183 
186 
187  };
188 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)