VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtHdrDrawableRenderData.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
14 
17 
18 #include <osg/Drawable>
19 #include <osg/Texture>
20 #include <osg/Texture2D>
21 
22 #include <array>
23 
24 namespace osg
25 {
26  class RenderInfo;
27  class Camera;
28  class State;
29 }
30 
31 namespace makVrv
32 {
33  class DtDe;
34 
35  class DtGlTexture;
36  class DtGlBuffer;
37  class DtGlProgram;
38 
39  class DtHdrDrawable;
40  struct DtHdrOptions;
41 
44 
47 
49  template <>
50  inline const char* creatorTypeName<DtHdrDrawableRenderData>(void) { return "DtHdrDrawableRenderDataCreator"; }
51 
56  {
57  public:
60 
62  virtual ~DtHdrDrawableRenderData();
63 
65  DtHdrDrawableRenderData() = delete;
67  DtHdrDrawableRenderData& operator=(const DtHdrDrawableRenderData& rhs) = delete;
68 
69  public:
71  virtual void initShaders();
72 
74  virtual void execute(osg::RenderInfo& renderInfo);
75 
77  virtual void cleanupGpuMemory();
78 
80  virtual void setInputTexture(osg::Texture* inputTex);
81 
83  virtual float localHdrOutputScale();
84 
85  protected:
87  DtHdrDrawableRenderData(DtDe& de, const DtHdrOptions& options, DtHdrDrawable* parent, osg::Texture*& lensFlareTexture);
88  protected:
90  virtual void initRenderTextures(const osg::Camera* osgCamera);
91 
93  virtual void downSample(DtGlTexture* src, DtGlTexture* dest, osg::State* state);
94 
97  virtual void downsample4x(DtGlTexture* src, DtGlTexture* dest, osg::State* state);
98 
100  virtual void extractHL(DtGlTexture* src, DtGlTexture* dest, osg::State* state);
101 
103  virtual void runPass(HDR_PASS prog, DtGlTexture* src, DtGlTexture* dest,
104  osg::State* state);
105 
107  virtual void blur(DtGlTexture* src, DtGlTexture* dest, DtGlTexture* temp,
108  int blurWidth, osg::State* state);
109 
111  virtual void getBufferPyramidSize(BUFFER_PYRAMID level, int* w, int* h);
112 
114  virtual void genStarStreak(int streak, float dir, float length);
115 
117  virtual void genGhostImage(const float* ghost_modulation1st, const float* ghost_modulation2nd, osg::State* state);
118 
120  virtual void composeEffect(void);
121 
124  virtual void toneMappingPass(osg::State* state);
125 
127  virtual void calculateLuminance(const osg::Camera* osgCamera);
128 
130  virtual float adaptiveLuminance(const osg::Camera* osgCamera);
131 
133  virtual bool adaptiveLuminanceCompute(const osg::Camera* osgCamera);
134 
136  virtual float adaptiveLuminanceRead(const osg::Camera* osgCamera);
137 
139  virtual float regularLuminance(const osg::Camera* osgCamera);
140 
142  virtual float silverLiningLuminance(const osg::Camera* osgCamera);
143 
145  virtual void computeColorModulationRedShift(float* color, float r, float g, float b, int num);
146  virtual void computeColorModulation(float* color, float r, float g, float b, int num);
147  virtual void computeColorModulationCoefficients();
148 
150  virtual void createComputeProgramIfNecessary(HDR_PASS pass, const std::string& name);
151  virtual void createBlurProgramsIfNecessary();
152 
155  virtual std::string preprocessorDefinesString(HDR_PASS pass);
156 
158  virtual unsigned int inputTextureId(unsigned int& target, const DtGlTexture* src, osg::State* state);
159 
161  virtual void streakPass0(int streak, float dec, const float step[2], float stride);
162  virtual void streakPass1(int streak, float dec, const float step[2], float stride);
163  virtual void streakPass2(int streak, float dec, const float step[2], float stride);
164 
166  virtual void ghostPass0(const float* ghost_modulation1st);
167  virtual void ghostPass1(const float* ghost_modulation2nd);
168 
170  virtual void gaussianBlurComposePass(void);
171  virtual void starStreakCompose(void);
172  virtual void finalGlarePass(void);
173 
175  virtual void initializeUniformLocations(HDR_PASS pass);
177  virtual void zeroOutUniformLocations();
178 
180  virtual void createToneMappingProgramIfNecessary(void);
181 
183  virtual void slot_hdrResolutionScaleChanged(int val);
184  protected:
186 
188 
190 
191  std::array<DtGlProgram*, PROGSIZE> myShaders;
192 
193  float myStarModulation1st[16];
194  float myStarModulation2nd[16];
195  float myStarModulation3rd[16];
196 
197  float myFilmicGhostModulation1st[16];
198  float myFilmicGhostModulation2nd[16];
199  float myCameraGhostModulation1st[16];
200  float myCameraGhostModulation2nd[16];
201 
202  float myHoriModulation1st[16];
203  float myHoriModulation2nd[16];
204  float myHoriModulation3rd[16];
205 
210 
213  DtGlTexture* myComposebuffer[LEVEL_TOTAL];
214  DtGlTexture* myBlurbufferA[LEVEL_TOTAL];
215  DtGlTexture* myBlurbufferB[LEVEL_TOTAL];
216 
217  DtGlTexture* myStreakbufferA[8];
218  DtGlTexture* myStreakbufferB[8];
220 
223 
225 
227 
228  unsigned int myLumNextBuffer;
229  const float* myLumNextBufferPtr;
230 
232 
236 
239 
242 
245 
249 
251 
254 
257 
259 
260  double myLastHdrFrameTime = -1;
261 
262  DtHdrDrawable* myParent = nullptr;
263 
264  // Signals and slots
266 
269  };
270 }
float myLastLuminanceValue
Definition: DtHdrDrawableRenderData.h:258
DtGlTexture * myGhost1stBuffer
Definition: DtHdrDrawableRenderData.h:221
double length(const dvec3 &theVec)
Definition: DtVecUtils.h:20
int myGaussianBlurComposeCoeffLoc
Definition: DtHdrDrawableRenderData.h:246
This class encapsulates all the (lazily) created OpenGL objects that are required for doing hdr...
Definition: DtHdrDrawableRenderData.h:55
DtGlTexture * myLumcurrent
Definition: DtHdrDrawableRenderData.h:226
DT_DLL_VRVCORE DtTaitBryan level(const DtCoordinateSystem &cs, const DtVector &localOrigin, double topoHeading)
Returns a level orientation with the topographic heading.
int myExtractHlTresholdAndScalarLoc
locations of various uniforms in the shaders
Definition: DtHdrDrawableRenderData.h:238
float myAspectRatio
Definition: DtHdrDrawableRenderData.h:189
int myBlurTexLoc
Definition: DtHdrDrawableRenderData.h:253
DtGlTexture * myGhost2ndBuffer
Definition: DtHdrDrawableRenderData.h:222
int myStarStreakStepSizeAndStrideLoc
Definition: DtHdrDrawableRenderData.h:240
DtVirtualBaseClassCreator< DtHdrDrawableRenderData, const DtHdrOptions &, DtHdrDrawable *, osg::Texture *& > DtHdrDrawableRenderDataCreator
creator
Definition: DtHdrDrawableRenderData.h:43
const DtHdrOptions & myOptions
Definition: DtHdrDrawableRenderData.h:187
int myGhostImageColorCoeffLoc
Definition: DtHdrDrawableRenderData.h:244
structure to hold all the HDR settings so they can more easily be passed to the drawable.
Definition: DtHdrTypes.h:54
std::array< DtGlProgram *, PROGSIZE > myShaders
Definition: DtHdrDrawableRenderData.h:191
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
int myGhostImageScalarLoc
Definition: DtHdrDrawableRenderData.h:243
DtGlTexture * myGlareBuffer
Definition: DtHdrDrawableRenderData.h:224
HDR_PASS
Definition: DtHdrTypes.h:18
unsigned int myLumNextBuffer
Definition: DtHdrDrawableRenderData.h:228
friend DtHdrDrawableRenderDataCreator
only friend can create
Definition: DtHdrDrawableRenderData.h:59
int myScalesBlurTexLuminanceSaturationLoc
Definition: DtHdrDrawableRenderData.h:255
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
BUFFER_PYRAMID
Definition: DtHdrTypes.h:41
double myLastAdpativeLumFrameTime
need to keep track of the previous frame time in draw implementation so this needs to be mutable...
Definition: DtHdrDrawableRenderData.h:235
int myElapsedTimeLoc
Definition: DtHdrDrawableRenderData.h:250
Contains DLL export macros.
int mySceneTexLoc
Definition: DtHdrDrawableRenderData.h:252
Base class to provide boost signal/slot management.
const float * myLumNextBufferPtr
Definition: DtHdrDrawableRenderData.h:229
DtGlTexture * myStreakbufferFinal
Definition: DtHdrDrawableRenderData.h:219
int myStarStreakColorCoeffLoc
Definition: DtHdrDrawableRenderData.h:241
osg::ref_ptr< osg::Texture > myLensMask
Definition: DtHdrDrawableRenderData.h:267
Definition: DtHdrTypes.h:49
const char * creatorTypeName< DtHdrDrawableRenderData >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtHdrDrawableRenderData.h:50
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
int myStarStreakComposeNumSamplersLoc
Definition: DtHdrDrawableRenderData.h:247
int myFinalGlarecomposeMixCoeffLoc
Definition: DtHdrDrawableRenderData.h:248
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlTexture.h:20
DtDe & myDe
Definition: DtHdrDrawableRenderData.h:185
class used to render hdr during the post processor camera draw
Definition: DtHdrDrawable.h:76
char * dest
Definition: lz4.h:440
DtSignalConnectionManager myConnections
Definition: DtHdrDrawableRenderData.h:265
osg::ref_ptr< osg::Texture > myInputTex
Definition: DtHdrDrawableRenderData.h:268
DtGlTexture * myInitialBuffer
Definition: DtHdrDrawableRenderData.h:231
int myBlurAmountGammaEnablePassThroughLoc
Definition: DtHdrDrawableRenderData.h:256

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)