VR-Forces 4.8 Class Documentation
 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 
57 namespace osg
58 {
59  class Object;
60  class State;
61  class RenderInfo;
62  class CopyOp;
63 }
64 
65 namespace makVrv
66 {
67  class DtDe;
68  class DtGlTexture;
69  class DtGlBuffer;
70 
73  {
74  public:
75 
76  enum HDR_PASS
77  { //Program ID enum
78  DOWNSAMPLE = 0,
96  PROGSIZE
97  };
98 
100  {
101  LEVEL_0 = 0,
107  LEVEL_TOTAL
108  };
109 
113  {
116  int hdrWidth;
119  float lumScaler;
121  float blendAmount;
122  float gamma;
124  float streakScale;
126  float streakDec;
128  float timeScale; //0.0 for instant
136  osg::Vec4f ghostScalar1;
137  osg::Vec4f ghostScalar2;
138  osg::Vec4f cameraMixCoeff;
139  osg::Vec4f gausCompCoeff;
140  osg::Vec4f blurScalar;
146  bool multiview;
147  };
148 
149  public:
151  DtHdrDrawable(DtDe &de, DtHdrOptions options, osg::Texture *lensFlareTexture);
152 
154  DtHdrDrawable(const DtHdrDrawable& orig, const osg::CopyOp& op);
155 
157  virtual ~DtHdrDrawable();
158  private:
160  DtHdrDrawable();
161 
164 
166  DtHdrDrawable& operator=(const DtHdrDrawable&);
167  public:
169  virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new DtHdrDrawable(*this,copyop); }
170  virtual osg::Object* cloneType() const { return NULL; }
171 
178  //virtual void releaseGLObjects(osg::State* state = 0) const;
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 
278  virtual unsigned int inputTextureId(unsigned int& target, const DtGlTexture* src, osg::State* state) const;
279 
281  virtual void streakPass0(int streak, float dec, const float step[2], float stride) const;
282  virtual void streakPass1(int streak, float dec, const float step[2], float stride) const;
283  virtual void streakPass2(int streak, float dec, const float step[2], float stride) const;
284 
286  virtual void ghostPass0(const float* ghost_modulation1st) const;
287  virtual void ghostPass1(const float* ghost_modulation2nd) const;
288 
290  virtual void gaussianBlurComposePass(void) const;
291  virtual void starStreakCompose(void) const;
292  virtual void finalGlarePass(void) const;
293 
295  virtual void initializeUniformLocations(HDR_PASS pass) const;
297  virtual void zeroOutUniformLocations();
298 
300  virtual void createToneMappingProgramIfNecessary(void) const;
301 
302  protected:
303  bool myEnabled;
304 
306 
307  static double theLastHdrFrameTime;
308 
310 
311  mutable unsigned int myMutableShaders[PROGSIZE];
312 
314 
316 
319 
320  float myStarModulation1st[16];
321  float myStarModulation2nd[16];
322  float myStarModulation3rd[16];
323 
324  float myFilmicGhostModulation1st[16];
325  float myFilmicGhostModulation2nd[16];
326  float myCameraGhostModulation1st[16];
327  float myCameraGhostModulation2nd[16];
328 
329  float myHoriModulation1st[16];
330  float myHoriModulation2nd[16];
331  float myHoriModulation3rd[16];
332 
337 
340  mutable DtGlTexture* myMutableComposebuffer[LEVEL_TOTAL];
341  mutable DtGlTexture* myMutableBlurbufferA[LEVEL_TOTAL];
342  mutable DtGlTexture* myMutableBlurbufferB[LEVEL_TOTAL];
343 
344  mutable DtGlTexture* myMutableStreakbufferA[8];
345  mutable DtGlTexture* myMutableStreakbufferB[8];
347 
350 
352 
354 
355  mutable unsigned int myMutableLumNext;
356  mutable const float* myMutableLumNextPtr;
357 
359 
363 
367 
371 
374 
378 
380 
381  mutable int myBlurAmountLoc;
382  mutable int myGammaLoc;
383  mutable int mySceneTexLoc;
384  mutable int myBlurTexLoc;
385  mutable int myLuminanceScaleLoc;
386  mutable int myBlurTexScaleLoc;
387  mutable int mySaturationScaleLoc;
389 
391  };
392 }
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
int myBlurTexLoc
Definition: DtHdrDrawable.h:384
float adaptiveLumMinDiff
Definition: DtHdrDrawable.h:135
Definition: DtHdrDrawable.h:83
Definition: DtHdrDrawable.h:85
int myMutableGaussianBlurComposeCoeffLoc
Definition: DtHdrDrawable.h:375
Definition: DtHdrDrawable.h:104
bool enableLensFlare
Definition: DtHdrDrawable.h:133
int myMutableStarStreakStepSizeLoc
Definition: DtHdrDrawable.h:368
DtGlTexture * myMutableGhost2ndBuffer
Definition: DtHdrDrawable.h:349
int numStreaks
Definition: DtHdrDrawable.h:123
virtual osg::Object * cloneType() const
Definition: DtHdrDrawable.h:170
int myGammaLoc
Definition: DtHdrDrawable.h:382
DtGlTexture * myMutableLumcurrent
Definition: DtHdrDrawable.h:353
float timeScale
Definition: DtHdrDrawable.h:128
osg::Vec4f ghostScalar2
Definition: DtHdrDrawable.h:137
Definition: DtHdrDrawable.h:82
bool enableBloom
Definition: DtHdrDrawable.h:131
float lumScaler
Definition: DtHdrDrawable.h:119
HDR_PASS
Definition: DtHdrDrawable.h:76
int myMutableGhostImageScalarLoc
Definition: DtHdrDrawable.h:372
int hdrHeight
Definition: DtHdrDrawable.h:117
int myEnablePassthroughLoc
Definition: DtHdrDrawable.h:388
Definition: DtHdrDrawable.h:81
static double theLastHdrFrameTime
Definition: DtHdrDrawable.h:307
float streakRotationOffset
Definition: DtHdrDrawable.h:125
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:370
int myMutableFinalGlarecomposeMixCoeffLoc
Definition: DtHdrDrawable.h:377
float luminanceMinValue
Definition: DtHdrDrawable.h:144
int myBlurTexScaleLoc
Definition: DtHdrDrawable.h:386
int chanHeight
Definition: DtHdrDrawable.h:115
int myMutableGhostImageColorCoeffLoc
Definition: DtHdrDrawable.h:373
Definition: DtHdrDrawable.h:80
Definition: DtHdrDrawable.h:92
float adaptiveLumMaxDiff
Definition: DtHdrDrawable.h:134
DtGlTexture * myMutableGhost1stBuffer
Definition: DtHdrDrawable.h:348
int myMutableExtractHlTresholdLoc
locations of various uniforms in the shaders
Definition: DtHdrDrawable.h:365
Definition: DtHdrDrawable.h:84
BUFFER_PYRAMID
Definition: DtHdrDrawable.h:99
int myBlurAmountLoc
Definition: DtHdrDrawable.h:381
float blendAmount
Definition: DtHdrDrawable.h:121
Definition: DtHdrDrawable.h:91
bool myEnableHdrPassthrough
Definition: DtHdrDrawable.h:318
bool exposureCorrelation
Definition: DtHdrDrawable.h:130
osg::ref_ptr< osg::Texture > myInputTex
Definition: DtHdrDrawable.h:305
Definition: DtHdrDrawable.h:95
unsigned int myMutableLumNext
Definition: DtHdrDrawable.h:355
Definition: DtHdrDrawable.h:79
const float * myMutableLumNextPtr
Definition: DtHdrDrawable.h:356
float luminanceMaxValue
Definition: DtHdrDrawable.h:143
Definition: DtHdrDrawable.h:90
float streakScale
Definition: DtHdrDrawable.h:124
structure to hold all the HDR settings so they can more easily be passed to the drawable.
Definition: DtHdrDrawable.h:112
bool myLumOverride
Definition: DtHdrDrawable.h:317
Definition: DtPostProcessorDrawable.h:23
DtHdrOptions myOptions
Definition: DtHdrDrawable.h:315
Definition: DtHdrDrawable.h:106
float adaptiveLumPostScale
Definition: DtHdrDrawable.h:142
osg::Vec4f ghostScalar1
Definition: DtHdrDrawable.h:136
bool myEnabled
Definition: DtHdrDrawable.h:303
int hdrWidth
Definition: DtHdrDrawable.h:116
float streakDec
Definition: DtHdrDrawable.h:126
Definition: DtHdrDrawable.h:88
bool adaptiveLuminance
Definition: DtHdrDrawable.h:129
Definition: DtHdrDrawable.h:102
osg::Vec4f gausCompCoeff
Definition: DtHdrDrawable.h:139
int chanWidth
Definition: DtHdrDrawable.h:114
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
int mySaturationScaleLoc
Definition: DtHdrDrawable.h:387
float adaptiveLumPreScale
Definition: DtHdrDrawable.h:141
DtGlTexture * myMutableGlareBuffer
Definition: DtHdrDrawable.h:351
This file contains the declaration of the class DtPostProcessorDrawable which is used for rendering p...
bool enableStreaks
Definition: DtHdrDrawable.h:132
Contains DLL export macros.
Definition: DtHdrDrawable.h:93
float myMutableLastLuminanceValue
Definition: DtHdrDrawable.h:390
Definition: DtHdrDrawable.h:89
double myMutableLastAdpativeLumFrameTime
need to keep track of the previous frame time in draw implementation so this needs to be mutable...
Definition: DtHdrDrawable.h:362
int myMutableElapsedTimeLoc
Definition: DtHdrDrawable.h:379
float gamma
Definition: DtHdrDrawable.h:122
virtual osg::Object * clone(const osg::CopyOp &copyop) const
required functions for derriving from osg::Drawable
Definition: DtHdrDrawable.h:169
Definition: DtHdrDrawable.h:94
Definition: DtHdrDrawable.h:86
osg::ref_ptr< osg::Texture > myLensMask
Definition: DtHdrDrawable.h:313
float streakStride
Definition: DtHdrDrawable.h:127
DtGlTexture * myMutableInitialBuffer
Definition: DtHdrDrawable.h:358
float myAspectRatio
Definition: DtHdrDrawable.h:309
osg::Vec4f cameraMixCoeff
Definition: DtHdrDrawable.h:138
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
int myMutableExtractHlScalarLoc
Definition: DtHdrDrawable.h:366
DtGlTexture * myMutableStreakbufferFinal
Definition: DtHdrDrawable.h:346
float lumThreshold
Definition: DtHdrDrawable.h:118
bool multiview
Definition: DtHdrDrawable.h:146
int mySceneTexLoc
Definition: DtHdrDrawable.h:383
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlTexture.h:20
float saturationScale
Definition: DtHdrDrawable.h:145
Definition: DtHdrDrawable.h:103
BUFFER_PYRAMID starGenLevel
Definition: DtHdrDrawable.h:120
osg::Vec4f blurScalar
Definition: DtHdrDrawable.h:140
int myLuminanceScaleLoc
Definition: DtHdrDrawable.h:385
int myMutableStarStreakComposeNumSamplersLoc
Definition: DtHdrDrawable.h:376
Definition: DtHdrDrawable.h:87
class used to render hdr during the post processor camera draw
Definition: DtHdrDrawable.h:72
char * dest
Definition: lz4.h:434
int myMutableStarStreakStrideLoc
Definition: DtHdrDrawable.h:369
Definition: DtHdrDrawable.h:105

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)