VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtHdrDrawable.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 // This file is derived from the HDR NVIDIA gameworks SDK example
6 //----------------------------------------------------------------------------------
7 // Multiple Files in folder: es3aep-kepler\HDR/
8 // SDK Version: v2.11
9 // Email: gameworks@nvidia.com
10 // Site: http://developer.nvidia.com/
11 //
12 // Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without
15 // modification, are permitted provided that the following conditions
16 // are met:
17 // * Redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 // * Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 // * Neither the name of NVIDIA CORPORATION nor the names of its
23 // contributors may be used to endorse or promote products derived
24 // from this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
34 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 //----------------------------------------------------------------------------------
39 
40 #pragma once
41 
46 
47 
48 // Get proper local export symbol
51 
52 #include <osg/Drawable>
53 #include <osg/Program>
54 #include <osg/Texture>
55 #include <osg/Texture2D>
56 
58 
59 namespace osg
60 {
61  class Object;
62  class State;
63  class RenderInfo;
64  class CopyOp;
65 }
66 
67 namespace makVrv
68 {
69  class DtDe;
70  class DtGlTexture;
71  class DtGlBuffer;
72  class DtGlProgram;
73 
76  {
77  public:
78 
79  enum HDR_PASS
80  { //Program ID enum
81  DOWNSAMPLE = 0,
99  PROGSIZE
100  };
101 
103  {
104  LEVEL_0 = 0,
110  LEVEL_TOTAL
111  };
112 
116  {
119  int hdrWidth;
122  float lumScaler;
124  float blendAmount;
125  float gamma;
127  float streakScale;
129  float streakDec;
131  float timeScale; //0.0 for instant
139  osg::Vec4f ghostScalar1;
140  osg::Vec4f ghostScalar2;
141  osg::Vec4f cameraMixCoeff;
142  osg::Vec4f gausCompCoeff;
143  osg::Vec4f blurScalar;
149  bool multiview;
150  };
151 
152  public:
154  DtHdrDrawable(DtDe &de, DtHdrOptions options, osg::Texture *lensFlareTexture);
155 
157  DtHdrDrawable(const DtHdrDrawable& orig, const osg::CopyOp& op);
158 
160  virtual ~DtHdrDrawable();
161  private:
163  DtHdrDrawable() = delete;
164 
166  DtHdrDrawable(const DtHdrDrawable&) = delete;
167 
169  DtHdrDrawable& operator=(const DtHdrDrawable&) = delete;
170  public:
172  virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new DtHdrDrawable(*this,copyop); }
173  virtual osg::Object* cloneType() const { return NULL; }
174 
179 
181  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
182 
184  virtual void setInputTexture(osg::Texture* inputTex);
185 
187  virtual void setEnabled( bool enabled );
188  virtual bool enabled();
189 
191  virtual DtHdrOptions& options();
192 
196  virtual void setLumOverride(bool lumOverride);
197 
199  // should just pass through without applying any effects
200  // used by SensorFX to turn off HDR on a per channel basis.
201  virtual void setHdrPassthrough(bool enable);
202  virtual bool hdrPassthrough();
203 
205  virtual void cleanupGpuMemory();
206 
208  virtual float localHdrOutputScale();
209 
210  protected:
211  virtual void initRenderTextures() const;
212 
214  virtual void downSample(DtGlTexture* src, DtGlTexture* dest, osg::State *state) const;
215 
218  virtual void downsample4x(DtGlTexture* src, DtGlTexture* dest, osg::State *state) const;
219 
221  virtual void extractHL(DtGlTexture* src, DtGlTexture* dest, osg::State *state) const;
222 
224  virtual void runPass(HDR_PASS prog, DtGlTexture* src, DtGlTexture* dest,
225  osg::State *state) const;
226 
228  virtual void blur(DtGlTexture* src, DtGlTexture* dest, DtGlTexture *temp,
229  int blurWidth, osg::State *state) const;
230 
232  virtual void getBufferPyramidSize(BUFFER_PYRAMID level, int* w, int* h) const;
233 
235  virtual void genStarStreak(int streak, float dir, float length) const;
236 
238  virtual void genGhostImage(const float* ghost_modulation1st,const float* ghost_modulation2nd, osg::State *state) const;
239 
241  virtual void composeEffect(void) const;
242 
245  virtual void toneMappingPass(osg::State *state) const;
246 
248  virtual void calculateLuminance(osg::State *state) const;
249 
251  virtual float adaptiveLuminance(osg::State* state) const;
252 
254  virtual bool adaptiveLuminanceCompute(osg::State* state) const;
255 
257  virtual float adaptiveLuminanceRead(osg::State* state) const;
258 
260  virtual float regularLuminance(osg::State* state) const;
261 
263  virtual float silverLiningLuminance(void) const;
264 
266  virtual void initShaders();
267 
269  virtual void computeColorModulationRedShift(float* color, float r, float g, float b, int num);
270  virtual void computeColorModulation(float* color, float r, float g, float b, int num);
271  virtual void computeColorModulationCoefficients();
272 
274  virtual void createComputeProgramIfNecessary(HDR_PASS pass, const std::string& name) const;
275  virtual void createBlurProgramsIfNecessary() const;
276 
279  virtual std::string preprocessorDefinesString(HDR_PASS pass) const;
280 
282  virtual unsigned int inputTextureId(unsigned int& target, const DtGlTexture* src, osg::State* state) const;
283 
285  virtual void streakPass0(int streak, float dec, const float step[2], float stride) const;
286  virtual void streakPass1(int streak, float dec, const float step[2], float stride) const;
287  virtual void streakPass2(int streak, float dec, const float step[2], float stride) const;
288 
290  virtual void ghostPass0(const float* ghost_modulation1st) const;
291  virtual void ghostPass1(const float* ghost_modulation2nd) const;
292 
294  virtual void gaussianBlurComposePass(void) const;
295  virtual void starStreakCompose(void) const;
296  virtual void finalGlarePass(void) const;
297 
299  virtual void initializeUniformLocations(HDR_PASS pass) const;
301  virtual void zeroOutUniformLocations();
302 
304  virtual void createToneMappingProgramIfNecessary(void) const;
305 
307  virtual void slot_hdrResolutionScaleChanged(int val);
308 
309  protected:
310  bool myEnabled;
311 
313 
314  static double theLastHdrFrameTime;
315 
317 
318  mutable std::array<DtGlProgram*, PROGSIZE> myMutableShaders;
319 
321 
323 
326 
327  float myStarModulation1st[16];
328  float myStarModulation2nd[16];
329  float myStarModulation3rd[16];
330 
331  float myFilmicGhostModulation1st[16];
332  float myFilmicGhostModulation2nd[16];
333  float myCameraGhostModulation1st[16];
334  float myCameraGhostModulation2nd[16];
335 
336  float myHoriModulation1st[16];
337  float myHoriModulation2nd[16];
338  float myHoriModulation3rd[16];
339 
340  // Signals and slots
342 
347 
350  mutable DtGlTexture* myMutableComposebuffer[LEVEL_TOTAL];
351  mutable DtGlTexture* myMutableBlurbufferA[LEVEL_TOTAL];
352  mutable DtGlTexture* myMutableBlurbufferB[LEVEL_TOTAL];
353 
354  mutable DtGlTexture* myMutableStreakbufferA[8];
355  mutable DtGlTexture* myMutableStreakbufferB[8];
357 
360 
362 
364 
365  mutable unsigned int myMutableLumNext;
366  mutable const float* myMutableLumNextPtr;
367 
369 
373 
376 
379 
382 
386 
388 
389  mutable int mySceneTexLoc;
390  mutable int myBlurTexLoc;
391 
394 
396  };
397 }
int myBlurTexLoc
Definition: DtHdrDrawable.h:390
float adaptiveLumMinDiff
Definition: DtHdrDrawable.h:138
Definition: DtHdrDrawable.h:86
Definition: DtHdrDrawable.h:88
int myMutableGaussianBlurComposeCoeffLoc
Definition: DtHdrDrawable.h:383
Definition: DtHdrDrawable.h:107
bool enableLensFlare
Definition: DtHdrDrawable.h:136
DtGlTexture * myMutableGhost2ndBuffer
Definition: DtHdrDrawable.h:359
int numStreaks
Definition: DtHdrDrawable.h:126
virtual osg::Object * cloneType() const
Definition: DtHdrDrawable.h:173
DtGlTexture * myMutableLumcurrent
Definition: DtHdrDrawable.h:363
float timeScale
Definition: DtHdrDrawable.h:131
DtSignalConnectionManager myConnections
Definition: DtHdrDrawable.h:341
osg::Vec4f ghostScalar2
Definition: DtHdrDrawable.h:140
Definition: DtHdrDrawable.h:85
bool enableBloom
Definition: DtHdrDrawable.h:134
float lumScaler
Definition: DtHdrDrawable.h:122
HDR_PASS
Definition: DtHdrDrawable.h:79
int myMutableGhostImageScalarLoc
Definition: DtHdrDrawable.h:380
int hdrHeight
Definition: DtHdrDrawable.h:120
Definition: DtHdrDrawable.h:84
static double theLastHdrFrameTime
Definition: DtHdrDrawable.h:314
float streakRotationOffset
Definition: DtHdrDrawable.h:128
DT_DLL_VRVCORE DtTaitBryan level(const DtCoordinateSystem &cs, const DtVector &localOrigin, double topoHeading)
Returns a level orientation with the topographic heading.
int myMutableStarStreakColorCoeffLoc
Definition: DtHdrDrawable.h:378
int myMutableFinalGlarecomposeMixCoeffLoc
Definition: DtHdrDrawable.h:385
float luminanceMinValue
Definition: DtHdrDrawable.h:147
int chanHeight
Definition: DtHdrDrawable.h:118
int myMutableExtractHlTresholdAndScalarLoc
locations of various uniforms in the shaders
Definition: DtHdrDrawable.h:375
int myMutableGhostImageColorCoeffLoc
Definition: DtHdrDrawable.h:381
Definition: DtHdrDrawable.h:83
Definition: DtHdrDrawable.h:95
float adaptiveLumMaxDiff
Definition: DtHdrDrawable.h:137
DtGlTexture * myMutableGhost1stBuffer
Definition: DtHdrDrawable.h:358
Definition: DtHdrDrawable.h:87
BUFFER_PYRAMID
Definition: DtHdrDrawable.h:102
float blendAmount
Definition: DtHdrDrawable.h:124
Definition: DtHdrDrawable.h:94
bool myEnableHdrPassthrough
Definition: DtHdrDrawable.h:325
bool exposureCorrelation
Definition: DtHdrDrawable.h:133
osg::ref_ptr< osg::Texture > myInputTex
Definition: DtHdrDrawable.h:312
Definition: DtHdrDrawable.h:98
unsigned int myMutableLumNext
Definition: DtHdrDrawable.h:365
Definition: DtHdrDrawable.h:82
int myScalesBlurTexLuminanceSaturationLoc
Definition: DtHdrDrawable.h:392
const float * myMutableLumNextPtr
Definition: DtHdrDrawable.h:366
float luminanceMaxValue
Definition: DtHdrDrawable.h:146
Definition: DtHdrDrawable.h:93
float streakScale
Definition: DtHdrDrawable.h:127
structure to hold all the HDR settings so they can more easily be passed to the drawable.
Definition: DtHdrDrawable.h:115
bool myLumOverride
Definition: DtHdrDrawable.h:324
Definition: DtPostProcessorDrawable.h:24
DtHdrOptions myOptions
Definition: DtHdrDrawable.h:322
int myMutableStarStreakStepSizeAndStrideLoc
Definition: DtHdrDrawable.h:377
Definition: DtHdrDrawable.h:109
float adaptiveLumPostScale
Definition: DtHdrDrawable.h:145
osg::Vec4f ghostScalar1
Definition: DtHdrDrawable.h:139
bool myEnabled
Definition: DtHdrDrawable.h:310
int hdrWidth
Definition: DtHdrDrawable.h:119
float streakDec
Definition: DtHdrDrawable.h:129
Definition: DtHdrDrawable.h:91
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
bool adaptiveLuminance
Definition: DtHdrDrawable.h:132
Definition: DtHdrDrawable.h:105
osg::Vec4f gausCompCoeff
Definition: DtHdrDrawable.h:142
int chanWidth
Definition: DtHdrDrawable.h:117
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
float adaptiveLumPreScale
Definition: DtHdrDrawable.h:144
DtGlTexture * myMutableGlareBuffer
Definition: DtHdrDrawable.h:361
This file contains the declaration of the class DtPostProcessorDrawable which is used for rendering p...
bool enableStreaks
Definition: DtHdrDrawable.h:135
Contains DLL export macros.
Definition: DtHdrDrawable.h:96
float myMutableLastLuminanceValue
Definition: DtHdrDrawable.h:395
Definition: DtHdrDrawable.h:92
double myMutableLastAdpativeLumFrameTime
need to keep track of the previous frame time in draw implementation so this needs to be mutable...
Definition: DtHdrDrawable.h:372
int myMutableElapsedTimeLoc
Definition: DtHdrDrawable.h:387
float gamma
Definition: DtHdrDrawable.h:125
virtual osg::Object * clone(const osg::CopyOp &copyop) const
required functions for derriving from osg::Drawable
Definition: DtHdrDrawable.h:172
Base class to provide boost signal/slot management.
Definition: DtHdrDrawable.h:97
Definition: DtHdrDrawable.h:89
osg::ref_ptr< osg::Texture > myLensMask
Definition: DtHdrDrawable.h:320
float streakStride
Definition: DtHdrDrawable.h:130
DtGlTexture * myMutableInitialBuffer
Definition: DtHdrDrawable.h:368
float myAspectRatio
Definition: DtHdrDrawable.h:316
osg::Vec4f cameraMixCoeff
Definition: DtHdrDrawable.h:141
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:70
std::array< DtGlProgram *, PROGSIZE > myMutableShaders
Definition: DtHdrDrawable.h:318
DtGlTexture * myMutableStreakbufferFinal
Definition: DtHdrDrawable.h:356
float lumThreshold
Definition: DtHdrDrawable.h:121
bool multiview
Definition: DtHdrDrawable.h:149
int mySceneTexLoc
Definition: DtHdrDrawable.h:389
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlTexture.h:20
float saturationScale
Definition: DtHdrDrawable.h:148
Definition: DtHdrDrawable.h:106
BUFFER_PYRAMID starGenLevel
Definition: DtHdrDrawable.h:123
osg::Vec4f blurScalar
Definition: DtHdrDrawable.h:143
int myMutableStarStreakComposeNumSamplersLoc
Definition: DtHdrDrawable.h:384
Definition: DtHdrDrawable.h:90
class used to render hdr during the post processor camera draw
Definition: DtHdrDrawable.h:75
char * dest
Definition: lz4.h:440
int myBlurAmountGammaEnablePassThroughLoc
Definition: DtHdrDrawable.h:393
Definition: DtHdrDrawable.h:108

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)