VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgLightingComponentTcsUserData.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 #include <vrvCore/DtKeyedData.h>
14 
16 #include <vrvMath/DtVector3.h>
17 #include <vrvMath/DtVector2.h>
18 
20 
21 #include <osg/Matrixd>
22 
23 #include <unordered_map>
24 #include <string>
25 #include <vector>
26 
27 namespace osg
28 {
29  class State;
30  class Camera;
31 }
32 
33 namespace makVrv
34 {
35  class DtGlBuffer;
36  class DtLightData;
37  class DtLightingComponentShaderConstants;
38  class DtTileSpaceLightGrid;
39  class DtLightComputeProgram;
40  class DtGlDeleteObjectManager;
41  class DtCoreGlBufferCreator;
42  class DtOsgLightManager;
43  class DtIndirectGlTextureObject;
44  class DtCoordinateSystem;
45 
46  class DtIndirectDefaultTexturesContainer;
47  class DtIndirectGlTextureObjectManager;
48  class DtIndirectGlTextureObject;
49 
52  {
53  public:
57  , myTotalCount(0)
58  {
59  //intentional nop
60  }
61  virtual void reset()
62  {
65  myTotalCount = 0;
66  }
67  public:
68  //Map of buffers for each indirect geometry, buffer pointer to number of lights in the buffer
69  std::unordered_map<DtGlBuffer*, int> myBufferToLightIndexMap;
72  };
73 
76  {
77  public:
78  DtOsgLightingComponentTcsUserData(DtDe& de, const std::string& name);
80  private:
85  public:
86  virtual void update(const std::vector<const DtLight*>& lights, const osg::State& state, const osg::Camera* camera);
87 
88  virtual void releaseGLObjects(void);
89 
91  virtual void bindRenderPassBuffers();
92 
93  virtual void updateLightSourceIndexBufferHandle(DtGlBuffer* handle, int maxNumLightSources);
94 
96  virtual const DtLightingComponentShaderConstants* shaderConstants(void) const;
98  protected:
100  virtual void packLights(const osg::Matrixd& normalMatrix, const std::vector<const DtLight*>& lights, const osg::State& state);
101 
103  virtual void updateTiledShadingData(const std::vector<const DtLight*>& lights, const osg::State& state, const osg::Camera* camera);
104 
107  virtual void updateTileLightIndexList(const std::vector<Matrix4_64>& projectionMatrix
108  , const std::vector<Vector3_64>& vWorldEye
109  , const std::vector<Vector3_64>& vWorldCenter
110  , const std::vector<Vector3_64>& vWorldUp
111  , const Vector2_uint32& viewportSize
112  , const osg::Camera* camera);
113 
115  virtual void updateLightingShaderUbo(const osg::State& state);
116 
117  virtual void bindCommonBuffers(const osg::State& state);
118 
121  int lightGridSize() const;
122 
124  virtual void deleteBuffers(void);
125 
127  virtual void createComputePassSsbos(void);
128  virtual void createRenderPassSsbos(void);
129 
131  virtual void deleteComputePassSsbos(void);
132  virtual void deleteRenderPassSsbos(void);
133 
135  virtual void releaseComputePassSsbos(void);
136  virtual void releaseRenderPassSsbos(void);
137 
140 
142  virtual void slot_reloadShader();
143 
145  virtual void slot_coordinateSystemChanged();
146 
148  virtual void slot_preTick();
150  Vector3_32 upVector(const osg::State& state) const;
151 
153  virtual void releaseTexture(DtIndirectGlTextureObject*& indirectGlTextureObject);
154 
155  protected:
158 
160  static const int theLightBlockBase = 6; // base binding for light UBO data
161  static const int theLightBlockCount = 5; // number of light UBOs
162  std::array<DtGlBuffer*, theLightBlockCount> myLightDataBlockUbos;
163 
169 
175 
177 
179 
180  std::vector<DtLight*> myViewSpaceLightsScratchPad;
181 
183 
184  // This goes in at binding 0 in the compute pass
186  // This goes in at binding 2 in the compute pass
188  // This is not applied directly. various of its address/offset are fed via myTileLightIndexBuffersInfoSsbo
190 
193 
195 
197 
201 
204 
207 protected:
208  //Constants for scaling the HDR scalars to values so the GUI can be a single decimal digit.
209  static const float theLightPointHdrScalar;
210  static const float theDynamicLightHdrScalar;
211  static const float theEmissiveTextureHdrScalar;
212  };
213 
216 
218  template <>
219  inline const char* creatorTypeName<DtOsgLightingComponentTcsUserData>(void) { return "DtOsgLightingComponentTcsUserDataCreator"; }
220 }
virtual void updateLightingShaderUbo(const osg::State &state)
update the light ubo
This class represents the per context, per camera data and operations on it via the DtOsgLightingComp...
Definition: DtOsgLightingComponentTcsUserData.h:75
This represents an arbitrary user pointer/data within DtKeyedData.
Definition: DtKeyedData.h:95
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
Definition: DtOsgLightingComponentTcsUserData.h:203
Helper class to pack lights into a buffer/texture.
Definition: DtLightData.h:42
virtual void slot_componentVisualizationModeChanged(int mode)
set the component visualization mode
int myTileLightIndexListSsboBinding
Definition: DtOsgLightingComponentTcsUserData.h:174
virtual void updateTileLightIndexList(const std::vector< Matrix4_64 > &projectionMatrix, const std::vector< Vector3_64 > &vWorldEye, const std::vector< Vector3_64 > &vWorldCenter, const std::vector< Vector3_64 > &vWorldUp, const Vector2_uint32 &viewportSize, const osg::Camera *camera)
Updates the per-light-grid index lists. called via updateTiledShadingData.
int myTotalCount
Definition: DtOsgLightingComponentTcsUserData.h:71
int myLightingShaderUboBiding
Definition: DtOsgLightingComponentTcsUserData.h:167
virtual void reset()
Definition: DtOsgLightingComponentTcsUserData.h:61
Definition: DtLightingComponentShaderConstants.h:28
DtTileLightIndexInfo myTileLightIndexInfo
Definition: DtOsgLightingComponentTcsUserData.h:178
Encapsulate an OpenGL texture object that is created/used in indirect rendering.
Definition: DtIndirectGlTextureObject.h:36
const char * creatorTypeName< DtOsgLightingComponentTcsUserData >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtOsgLightingComponentTcsUserData.h:219
2 dimensional vector
Vector3_32 upVector(const osg::State &state) const
up vector
DtTileSpaceLightGrid * myTileSpaceLightGrid
Definition: DtOsgLightingComponentTcsUserData.h:176
DtVirtualBaseClassCreator< DtOsgLightingComponentTcsUserData, const std::string & > DtOsgLightingComponentTcsUserDataCreator
creator
Definition: DtOsgLightingComponentTcsUserData.h:215
creator for DtCoreGlBuffer
Definition: DtCoreGlBuffer.h:66
This manager manages the lifetime of the actual gl texture objects (gl unsigned ints) in the indirect...
Definition: DtIndirectGlTextureObjectManager.h:60
DtOsgLightingComponentTcsUserData & operator=(const DtOsgLightingComponentTcsUserData &rhs)=delete
virtual const DtLightingComponentShaderConstants * shaderConstants(void) const
get the shader constants
virtual void slot_reloadShader()
reload the light source compute shaders
static const float theLightPointHdrScalar
Definition: DtOsgLightingComponentTcsUserData.h:209
DtLightingComponentShaderConstants * myLightingShaderUboConstants
Definition: DtOsgLightingComponentTcsUserData.h:168
DtGlBuffer * myTileLightIndexListPreComputeSsbo
Definition: DtOsgLightingComponentTcsUserData.h:189
DtIndirectDefaultTexturesContainer & myIndirectDefaultTexturesContainer
Definition: DtOsgLightingComponentTcsUserData.h:202
virtual void releaseTexture(DtIndirectGlTextureObject *&indirectGlTextureObject)
internal
virtual void packLights(const osg::Matrixd &normalMatrix, const std::vector< const DtLight * > &lights, const osg::State &state)
pack lights and update the ubo
DtLightData * myLightGrid
Parameters of lights are stored in this structure.
Definition: DtOsgLightingComponentTcsUserData.h:157
DtIndirectGlTextureObject * myModelDebugTexture
Definition: DtOsgLightingComponentTcsUserData.h:206
DtGlBuffer * myTileLightIntersectionDataSsbo
Definition: DtOsgLightingComponentTcsUserData.h:187
3 dimensional vector
static const int theLightBlockCount
Definition: DtOsgLightingComponentTcsUserData.h:161
static const float theEmissiveTextureHdrScalar
Definition: DtOsgLightingComponentTcsUserData.h:211
virtual void bindRenderPassBuffers()
This is called by the DtLightingComponentStateAttribute.
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
virtual void releaseComputePassSsbos(void)
release buffers needed in compute and render passes
virtual void deleteComputePassSsbos(void)
delete buffers needed in compute and render passes
DtOsgLightManager & myOsgLightManager
Definition: DtOsgLightingComponentTcsUserData.h:196
virtual void slot_preTick()
pre tick function
DtGlBuffer * myTileLightIndexListSsbo
Holds a set of indexes, one per light tile. This can get big, so cannot fit in a UBO. This goes in at binding 12 in the lighting pass This is actually also written to by the compute pass, to be read in the render pass.
Definition: DtOsgLightingComponentTcsUserData.h:173
static const int theLightBlockBase
These go in at bindings 6-10 in the lighting pass.
Definition: DtOsgLightingComponentTcsUserData.h:160
DtCoordinateSystem * myCoordinateSystem
local clone of the system wide coordinate system. for thread safety.
Definition: DtOsgLightingComponentTcsUserData.h:200
virtual void createComputePassSsbos(void)
create buffers needed in compute and render passes
Light class.
DtGlBuffer * myLightingShaderUbo
Lighting shader ubo This goes in at binding 11 in the lighting pass.
Definition: DtOsgLightingComponentTcsUserData.h:166
DtOsgLightManager receives LightSource nodes from the DtOsgCullVisitor, and collects them all here wh...
Definition: DtOsgLightManager.h:55
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
DtCoreGlBufferCreator & myCoreGlBufferCreator
Definition: DtOsgLightingComponentTcsUserData.h:192
virtual void updateTiledShadingData(const std::vector< const DtLight * > &lights, const osg::State &state, const osg::Camera *camera)
run the compute shaders in order to update the per camera lighting data and bin the lights in screens...
loads and contains various core default textures used by the indirect system
Definition: DtIndirectDefaultTexturesContainer.h:30
int lightGridSize() const
Returns the number of lights in the light grid Not virtual. Called via constructor.
virtual void bindCommonBuffers(const osg::State &state)
Class doing all the heavy lifting in regards of forward+ lighting.
Definition: DtTileSpaceLightGrid.h:42
DtOsgLightingComponentTcsUserData()=delete
not allowed
virtual void deleteBuffers(void)
called on destruction
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
std::unordered_map< DtGlBuffer *, int > myBufferToLightIndexMap
Definition: DtOsgLightingComponentTcsUserData.h:69
DtGlBuffer * myTileLightIndexBuffersInfoSsbo
Definition: DtOsgLightingComponentTcsUserData.h:185
struct for holding information about a camera&#39;s tile light index map
Definition: DtOsgLightingComponentTcsUserData.h:51
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
DtSignalConnectionManager myConnections
Definition: DtOsgLightingComponentTcsUserData.h:194
Base class to provide boost signal/slot management.
DtIndirectGlTextureObject * myBrdfLookUpTexture
Definition: DtOsgLightingComponentTcsUserData.h:205
Vaos are OpenGL context specific. They need to be deleted in the context they are created in...
Definition: DtGlDeleteObjectManager.h:58
const char int mode
Definition: ioapi.h:38
virtual void updateLightSourceIndexBufferHandle(DtGlBuffer *handle, int maxNumLightSources)
int myBufferChunkCount
Definition: DtOsgLightingComponentTcsUserData.h:70
Contains DLL export macros.
DtLightComputeProgram * myLightComputeProgram
Definition: DtOsgLightingComponentTcsUserData.h:182
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
DtTileLightIndexInfo()
Definition: DtOsgLightingComponentTcsUserData.h:54
static const float theDynamicLightHdrScalar
Definition: DtOsgLightingComponentTcsUserData.h:210
virtual void slot_coordinateSystemChanged()
slot for when the coordinate system changes
std::vector< DtLight * > myViewSpaceLightsScratchPad
Definition: DtOsgLightingComponentTcsUserData.h:180
virtual void update(const std::vector< const DtLight * > &lights, const osg::State &state, const osg::Camera *camera)
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtOsgLightingComponentTcsUserData.h:191
Contains the DtKeyedData class declaration.
std::array< DtGlBuffer *, theLightBlockCount > myLightDataBlockUbos
Definition: DtOsgLightingComponentTcsUserData.h:162
Class that encapsulates the 2 pass (setup, sort) computation of lights affecting the screen space til...
Definition: DtLightComputeProgram.h:46

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)