VR-Forces 4.8 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) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
17 #include <osg/Uniform>
18 #include <osg/Texture2D>
19 
20 #include <vector>
21 #include <boost/array.hpp> // TODO: replace with std::array when c++11 is available
22 
24 
25 namespace osg
26 {
27  class Matrixd;
28 }
29 
30 namespace makVrv
31 {
32  class DtLight;
33  class DtLightData;
34  class DtTileSpaceLightGrid;
35  class DtGlSimpleTexture;
36  class DtGlBuffer;
37  class DtGlTextureBufferObject;
38  class DeDe;
39 
40  class TextureApplyAttribute;
41  class TextureBufferObjectApplyAttribute;
42  class DtUniformBufferObjectApplyAttribute;
43  class DtShaderStorageBufferApplyAttribute;
44 
50  {
51  public:
53  DtOsgLightingComponent(int maxLights, DtDe& de);
54 
56  virtual ~DtOsgLightingComponent();
57  private:
60 
63 
66  public:
68  virtual void update(const VectorLights& lights, const osg::State& state);
69 
71  virtual void setMaxLights(int maxNumLights);
72 
73  virtual const Vector2_uint32& tileSize(void) const;
74  virtual const Vector2_uint32& gridMaxDims(void) const;
75 
77  virtual osg::Uniform* getEnableLightingUniform() const;
78 
80  virtual void setAmbientFactor(float ambientFactor);
81 
83  virtual void setUseGlobalAmbient(bool useGlobalAmbient);
84 
86  virtual void setDiffuseFactor(float diffuseFactor);
87 
89  virtual void setUseGlobalDiffuse(bool useGlobalDiffuse);
90 
92  virtual void setUseHDR(bool useHDR);
93 
95  virtual void setDirty(bool isDirty) { myDirty = isDirty; }
96 
98  virtual void setEmissionFactor(float emissionFactor);
99 
101  virtual bool dirty() const { return myDirty; }
102 
103  virtual void releaseGLObjects(void);
104 
105  // DtOsgStateComponent interface
107  virtual bool install(osg::StateSet* stateset);
108 
110  virtual bool uninstall(osg::StateSet* stateset);
111 
112  public:
113  static int textureStartOffset(void);
114 
115  protected:
116  virtual void setLightPointScale(double scale);
117  virtual void setDynamicLightScale(double scale);
118  virtual void setEmissiveTextureScale(double scale);
119  virtual void setSpecularScale(double scale);
120  virtual void setShininessScale(double scale);
121 
122  virtual osg::ref_ptr<osg::Uniform> createUniform(const std::string& name, osg::Uniform::Type type, int count=1);
123 
124  virtual void packLights(const osg::Matrixd& normalMatrix, const VectorLights& lights, const osg::State& state);
125  virtual void updateTextureLightDataGrid(void);
126  virtual void updateTiledShadingData(const VectorLights& lights, const osg::State& state);
127 
129  virtual void updateTileLightIndexList();
131  virtual void updateTileLightGridCountOffsets();
132 
134  virtual int lightGridSize();
136  virtual int maxUboSize();
137 
138  protected:
139 
142 
143  std::vector< osg::ref_ptr<osg::Uniform> > myUniforms;
144 
145  // Parameters of lights are stored in this structure
147 
148  // TODO: replace with std::array once c++11 is available.
149  boost::array<DtGlBuffer*, DtBindingManager::theLightBlockCount> myLightUBO;
150 
152 
158 
161 
165 
167 
170 
177  bool myUseHDR;
178  bool myDirty;
180 
183 
189 
194 
196 
198 
201 
203 
205 
207 
208  GLint myMaxUboSizeInBytes; // queried from GL
209  int myLightGridSize; // max size of light grid
210 
211  const DtBindingManager& myBindingManager; // reference to the binding manager
212  };
213 }
Contains the DtOsgTextureBufferObjectApplyAttribute class.
osg::ref_ptr< osg::Uniform > myLightPointScaleUniform
Definition: DtOsgLightingComponent.h:184
std::vector< osg::ref_ptr< osg::Uniform > > myUniforms
Definition: DtOsgLightingComponent.h:143
Helper class to pack lights into a buffer/texture.
Definition: DtLightData.h:44
virtual void setDirty(bool isDirty)
Sets dirty state for reinstallation.
Definition: DtOsgLightingComponent.h:95
bool myUseGlobalAmbient
Definition: DtOsgLightingComponent.h:172
DtGlBuffer * myTileLightGridCountOffsetsSSBO
Holds tile grid space offset and count pairs into the light data.
Definition: DtOsgLightingComponent.h:154
osg::ref_ptr< osg::Uniform > myDynamicLightScaleUniform
Definition: DtOsgLightingComponent.h:185
DtGlSimpleTexture * myColorRampTexture
Definition: DtOsgLightingComponent.h:159
osg::ref_ptr< osg::Uniform > myEnableLightingUniform
Definition: DtOsgLightingComponent.h:140
DtLightData * myLightGrid
Definition: DtOsgLightingComponent.h:146
osg::ref_ptr< osg::Uniform > myBDRFLutUniform
Definition: DtOsgLightingComponent.h:191
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
bool myUseHDR
Definition: DtOsgLightingComponent.h:177
osg::ref_ptr< osg::Uniform > mySpecularScaleUniform
Definition: DtOsgLightingComponent.h:187
osg::ref_ptr< osg::Uniform > myLightGridTileDimUniform
Definition: DtOsgLightingComponent.h:168
Wrapper for OpenGL Texture.
Definition: DtGlSimpleTexture.h:35
osg::ref_ptr< osg::Uniform > myEmissionFactorUniform
Definition: DtOsgLightingComponent.h:179
const DtBindingManager & myBindingManager
Definition: DtOsgLightingComponent.h:211
Contains the vrvOsg::DtBindingManager class.
Contains the DtOsgTextureApplyAttribute class.
osg::ref_ptr< osg::Uniform > myAmbientFactorUniform
Definition: DtOsgLightingComponent.h:171
osg::ref_ptr< osg::Uniform > myDiffuseFactorUniform
Definition: DtOsgLightingComponent.h:174
uint32 myTileLightGridCountOffsetsSize
Definition: DtOsgLightingComponent.h:200
bool myDirty
Definition: DtOsgLightingComponent.h:178
osg::ref_ptr< osg::Uniform > myUseGlobalDiffuseUniform
Definition: DtOsgLightingComponent.h:176
osg::ref_ptr< osg::Uniform > myModelTransmittanceUniform
Definition: DtOsgLightingComponent.h:182
osg::ref_ptr< osg::Uniform > myLightingOffClampUniform
Definition: DtOsgLightingComponent.h:141
DtSignalConnectionManager myConnections
Definition: DtOsgLightingComponent.h:204
Manage interface block bindings.
Definition: DtBindingManager.h:43
osg::ref_ptr< osg::Uniform > myViewportSizeUniform
Definition: DtOsgLightingComponent.h:166
osg::ref_ptr< osg::Uniform > myEmissiveTextureScaleUniform
Definition: DtOsgLightingComponent.h:186
DtGlBuffer * myTileLightIndexListSSBO
Holds a set of indexes, one per light tile.
Definition: DtOsgLightingComponent.h:157
osg::ref_ptr< DtUniformBufferObjectApplyAttribute > myUniformBufferObjectApplyAttribute
Definition: DtOsgLightingComponent.h:163
osg::ref_ptr< osg::Uniform > myModelTypeDefaultUniform
Definition: DtOsgLightingComponent.h:195
osg::ref_ptr< osg::Texture2D > myBDRFLutTexture
Definition: DtOsgLightingComponent.h:192
Light class.
osg::ref_ptr< osg::Uniform > myUseGlobalAmbientUniform
Definition: DtOsgLightingComponent.h:173
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
osg::ref_ptr< osg::Uniform > myTransmittanceFactorUniform
Definition: DtOsgLightingComponent.h:181
bool myIsInstalled
Definition: DtOsgLightingComponent.h:202
osg::ref_ptr< osg::Uniform > myUpVectorUniform
Definition: DtOsgLightingComponent.h:190
osg::ref_ptr< osg::Uniform > myColorRampTextureUniform
Definition: DtOsgLightingComponent.h:160
Class doing all the heavy lifting in regards of forward+ lighting.
Definition: DtTileSpaceLightGrid.h:40
boost::array< DtGlBuffer *, DtBindingManager::theLightBlockCount > myLightUBO
Definition: DtOsgLightingComponent.h:149
bool myUseGlobalDiffuse
Definition: DtOsgLightingComponent.h:175
int myLightGridSize
Definition: DtOsgLightingComponent.h:209
A generic OpenGL buffer.
Definition: DtGlBuffer.h:25
osg::ref_ptr< DtShaderStorageBufferApplyAttribute > myShaderStorageBufferApplyAttribute
Definition: DtOsgLightingComponent.h:164
osg::ref_ptr< osg::Uniform > myShininessScaleUniform
Definition: DtOsgLightingComponent.h:188
VectorLights myViewSpaceLightsScratchPad
Definition: DtOsgLightingComponent.h:197
Base class to provide boost signal/slot management.
osg::ref_ptr< TextureApplyAttribute > myTextureApplyAttribute
Definition: DtOsgLightingComponent.h:162
Base class for components that affect the state on a subset of the scene graph, injecting state...
Definition: DtOsgStateComponent.h:34
osg::ref_ptr< osg::Image > myBDRFLutImage
Definition: DtOsgLightingComponent.h:193
unsigned int uint32
Definition: DtCommonTypes.h:28
DtTileSpaceLightGrid * myTileSpaceLightGrid
Definition: DtOsgLightingComponent.h:151
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
Contains the DtOsgStateComponent class.
virtual bool dirty() const
Checks if component needs to be re-installed.
Definition: DtOsgLightingComponent.h:101
int32 * myTileLightGridCountOffsets
Definition: DtOsgLightingComponent.h:199
osg::ref_ptr< osg::Uniform > myLightGridMaxDimUniform
Definition: DtOsgLightingComponent.h:169
static bool bColorRampTextureWasTried
Definition: DtOsgLightingComponent.h:206
State component that injects lighting shaders and uniforms into a state set.
Definition: DtOsgLightingComponent.h:49
GLint myMaxUboSizeInBytes
Definition: DtOsgLightingComponent.h:208

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)