VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
makVrv::DtHdrDrawableRenderData Class Reference

This class encapsulates all the (lazily) created OpenGL objects that are required for doing hdr. It also executes the various hdr passes and the final tone mapping pass..

Public Member Functions

virtual ~DtHdrDrawableRenderData ()
 
 DtHdrDrawableRenderData ()=delete
 
 DtHdrDrawableRenderData (const DtHdrDrawableRenderData &rhs)=delete
 
DtHdrDrawableRenderDataoperator= (const DtHdrDrawableRenderData &rhs)=delete
 
virtual void initShaders ()
 
virtual void execute (osg::RenderInfo &renderInfo)
 
virtual void cleanupGpuMemory ()
 
virtual void setInputTexture (osg::Texture *inputTex)
 
virtual float localHdrOutputScale ()
 

Public Attributes

friend DtHdrDrawableRenderDataCreator
 

Protected Member Functions

 DtHdrDrawableRenderData (DtDe &de, const DtHdrOptions &options, DtHdrDrawable *parent, osg::Texture *&lensFlareTexture)
 
virtual void initRenderTextures (const osg::Camera *osgCamera)
 
virtual void downSample (DtGlTexture *src, DtGlTexture *dest, osg::State *state)
 
virtual void downsample4x (DtGlTexture *src, DtGlTexture *dest, osg::State *state)
 
virtual void extractHL (DtGlTexture *src, DtGlTexture *dest, osg::State *state)
 
virtual void runPass (HDR_PASS prog, DtGlTexture *src, DtGlTexture *dest, osg::State *state)
 
virtual void blur (DtGlTexture *src, DtGlTexture *dest, DtGlTexture *temp, int blurWidth, osg::State *state)
 
virtual void getBufferPyramidSize (BUFFER_PYRAMID level, int *w, int *h)
 
virtual void genStarStreak (int streak, float dir, float length)
 
virtual void genGhostImage (const float *ghost_modulation1st, const float *ghost_modulation2nd, osg::State *state)
 
virtual void composeEffect (void)
 
virtual void toneMappingPass (osg::State *state)
 
virtual void calculateLuminance (const osg::Camera *osgCamera)
 
virtual float adaptiveLuminance (const osg::Camera *osgCamera)
 
virtual bool adaptiveLuminanceCompute (const osg::Camera *osgCamera)
 
virtual float adaptiveLuminanceRead (const osg::Camera *osgCamera)
 
virtual float regularLuminance (const osg::Camera *osgCamera)
 
virtual float silverLiningLuminance (const osg::Camera *osgCamera)
 
virtual void computeColorModulationRedShift (float *color, float r, float g, float b, int num)
 
virtual void computeColorModulation (float *color, float r, float g, float b, int num)
 
virtual void computeColorModulationCoefficients ()
 
virtual void createComputeProgramIfNecessary (HDR_PASS pass, const std::string &name)
 
virtual void createBlurProgramsIfNecessary ()
 
virtual std::string preprocessorDefinesString (HDR_PASS pass)
 
virtual unsigned int inputTextureId (unsigned int &target, const DtGlTexture *src, osg::State *state)
 
virtual void streakPass0 (int streak, float dec, const float step[2], float stride)
 
virtual void streakPass1 (int streak, float dec, const float step[2], float stride)
 
virtual void streakPass2 (int streak, float dec, const float step[2], float stride)
 
virtual void ghostPass0 (const float *ghost_modulation1st)
 
virtual void ghostPass1 (const float *ghost_modulation2nd)
 
virtual void gaussianBlurComposePass (void)
 
virtual void starStreakCompose (void)
 
virtual void finalGlarePass (void)
 
virtual void initializeUniformLocations (HDR_PASS pass)
 
virtual void zeroOutUniformLocations ()
 
virtual void createToneMappingProgramIfNecessary (void)
 
virtual void slot_hdrResolutionScaleChanged (int val)
 

Protected Attributes

DtDemyDe
 
const DtHdrOptionsmyOptions
 
float myAspectRatio
 
std::array< DtGlProgram
*, PROGSIZE
myShaders
 
float myStarModulation1st [16]
 
float myStarModulation2nd [16]
 
float myStarModulation3rd [16]
 
float myFilmicGhostModulation1st [16]
 
float myFilmicGhostModulation2nd [16]
 
float myCameraGhostModulation1st [16]
 
float myCameraGhostModulation2nd [16]
 
float myHoriModulation1st [16]
 
float myHoriModulation2nd [16]
 
float myHoriModulation3rd [16]
 
DtGlTexturemyComposebuffer [LEVEL_TOTAL]
 
DtGlTexturemyBlurbufferA [LEVEL_TOTAL]
 
DtGlTexturemyBlurbufferB [LEVEL_TOTAL]
 
DtGlTexturemyStreakbufferA [8]
 
DtGlTexturemyStreakbufferB [8]
 
DtGlTexturemyStreakbufferFinal
 
DtGlTexturemyGhost1stBuffer
 
DtGlTexturemyGhost2ndBuffer
 
DtGlTexturemyGlareBuffer
 
DtGlTexturemyLumcurrent
 
unsigned int myLumNextBuffer
 
const float * myLumNextBufferPtr
 
DtGlTexturemyInitialBuffer
 
double myLastAdpativeLumFrameTime
 
int myExtractHlTresholdAndScalarLoc
 
int myStarStreakStepSizeAndStrideLoc
 
int myStarStreakColorCoeffLoc
 
int myGhostImageScalarLoc
 
int myGhostImageColorCoeffLoc
 
int myGaussianBlurComposeCoeffLoc
 
int myStarStreakComposeNumSamplersLoc
 
int myFinalGlarecomposeMixCoeffLoc
 
int myElapsedTimeLoc
 
int mySceneTexLoc
 
int myBlurTexLoc
 
int myScalesBlurTexLuminanceSaturationLoc
 
int myBlurAmountGammaEnablePassThroughLoc
 
float myLastLuminanceValue
 
double myLastHdrFrameTime = -1
 
DtHdrDrawablemyParent = nullptr
 
DtSignalConnectionManager myConnections
 
osg::ref_ptr< osg::Texture > myLensMask
 
osg::ref_ptr< osg::Texture > myInputTex
 

Constructor & Destructor Documentation

virtual makVrv::DtHdrDrawableRenderData::~DtHdrDrawableRenderData ( )
virtual

destructor

makVrv::DtHdrDrawableRenderData::DtHdrDrawableRenderData ( )
delete

not allowed

makVrv::DtHdrDrawableRenderData::DtHdrDrawableRenderData ( const DtHdrDrawableRenderData rhs)
delete
makVrv::DtHdrDrawableRenderData::DtHdrDrawableRenderData ( DtDe de,
const DtHdrOptions options,
DtHdrDrawable parent,
osg::Texture *&  lensFlareTexture 
)
protected

protected constructor

Member Function Documentation

DtHdrDrawableRenderData& makVrv::DtHdrDrawableRenderData::operator= ( const DtHdrDrawableRenderData rhs)
delete
virtual void makVrv::DtHdrDrawableRenderData::initShaders ( )
virtual

initialize the rest of the HDR shaders.

virtual void makVrv::DtHdrDrawableRenderData::execute ( osg::RenderInfo &  renderInfo)
virtual

do hdr

virtual void makVrv::DtHdrDrawableRenderData::cleanupGpuMemory ( )
virtual

clean up

virtual void makVrv::DtHdrDrawableRenderData::setInputTexture ( osg::Texture *  inputTex)
virtual

set the input texture

virtual float makVrv::DtHdrDrawableRenderData::localHdrOutputScale ( )
virtual

hdr output scale this drawable calulated or used last frame

virtual void makVrv::DtHdrDrawableRenderData::initRenderTextures ( const osg::Camera *  osgCamera)
protectedvirtual

initializes all the render textures if they have not been initialized yet

virtual void makVrv::DtHdrDrawableRenderData::downSample ( DtGlTexture src,
DtGlTexture dest,
osg::State *  state 
)
protectedvirtual

downsample the the src texture into the dest texture (or upsample if the dest is larger)

virtual void makVrv::DtHdrDrawableRenderData::downsample4x ( DtGlTexture src,
DtGlTexture dest,
osg::State *  state 
)
protectedvirtual

same as downsample except it samples a 4x4 square in the src for each sample in the dest this helps reduce flickering for really bright objects like light points.

virtual void makVrv::DtHdrDrawableRenderData::extractHL ( DtGlTexture src,
DtGlTexture dest,
osg::State *  state 
)
protectedvirtual

extract the anything above the lumThreshold and put it in the dest render texture

virtual void makVrv::DtHdrDrawableRenderData::runPass ( HDR_PASS  prog,
DtGlTexture src,
DtGlTexture dest,
osg::State *  state 
)
protectedvirtual

run the specified prog on the src and put the result in dest. Used mostly for blur shaders.

virtual void makVrv::DtHdrDrawableRenderData::blur ( DtGlTexture src,
DtGlTexture dest,
DtGlTexture temp,
int  blurWidth,
osg::State *  state 
)
protectedvirtual

blur pass

virtual void makVrv::DtHdrDrawableRenderData::getBufferPyramidSize ( BUFFER_PYRAMID  level,
int w,
int h 
)
protectedvirtual

calculate the buffer size for a particular blur level

virtual void makVrv::DtHdrDrawableRenderData::genStarStreak ( int  streak,
float  dir,
float  length 
)
protectedvirtual

run the star streak shaders for a particular streak direction and length

virtual void makVrv::DtHdrDrawableRenderData::genGhostImage ( const float *  ghost_modulation1st,
const float *  ghost_modulation2nd,
osg::State *  state 
)
protectedvirtual

run the shaders to generate the ghosting/lens flare effect

virtual void makVrv::DtHdrDrawableRenderData::composeEffect ( void  )
protectedvirtual

compose the three HDR effects into a single render texture.

virtual void makVrv::DtHdrDrawableRenderData::toneMappingPass ( osg::State *  state)
protectedvirtual

run the final tone mapping pass that combines the effects texture with the main rendering and scales everything appropriately

virtual void makVrv::DtHdrDrawableRenderData::calculateLuminance ( const osg::Camera *  osgCamera)
protectedvirtual

calculate the luminance scaling to use in the tone mapping

virtual float makVrv::DtHdrDrawableRenderData::adaptiveLuminance ( const osg::Camera *  osgCamera)
protectedvirtual

adaptive luminance (do the pass, read, etc)

virtual bool makVrv::DtHdrDrawableRenderData::adaptiveLuminanceCompute ( const osg::Camera *  osgCamera)
protectedvirtual

compute adaptive luminance

virtual float makVrv::DtHdrDrawableRenderData::adaptiveLuminanceRead ( const osg::Camera *  osgCamera)
protectedvirtual

read back the adaptive luminance

virtual float makVrv::DtHdrDrawableRenderData::regularLuminance ( const osg::Camera *  osgCamera)
protectedvirtual

non-adaptive luminance

virtual float makVrv::DtHdrDrawableRenderData::silverLiningLuminance ( const osg::Camera *  osgCamera)
protectedvirtual

luminance per Silver Lining

virtual void makVrv::DtHdrDrawableRenderData::computeColorModulationRedShift ( float *  color,
float  r,
float  g,
float  b,
int  num 
)
protectedvirtual

helper functions used for creating color constants

virtual void makVrv::DtHdrDrawableRenderData::computeColorModulation ( float *  color,
float  r,
float  g,
float  b,
int  num 
)
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::computeColorModulationCoefficients ( )
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::createComputeProgramIfNecessary ( HDR_PASS  pass,
const std::string &  name 
)
protectedvirtual

helper function to create compute program

virtual void makVrv::DtHdrDrawableRenderData::createBlurProgramsIfNecessary ( )
protectedvirtual
virtual std::string makVrv::DtHdrDrawableRenderData::preprocessorDefinesString ( HDR_PASS  pass)
protectedvirtual

preprocessor string taking into account the current options. NOTE: This is a different signature than base class function (but calls up to base class)

virtual unsigned int makVrv::DtHdrDrawableRenderData::inputTextureId ( unsigned int target,
const DtGlTexture src,
osg::State *  state 
)
protectedvirtual

get the OpenGL texture id and target (2D for regular, 2D array if in VR)

virtual void makVrv::DtHdrDrawableRenderData::streakPass0 ( int  streak,
float  dec,
const float  step[2],
float  stride 
)
protectedvirtual

streak passes

virtual void makVrv::DtHdrDrawableRenderData::streakPass1 ( int  streak,
float  dec,
const float  step[2],
float  stride 
)
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::streakPass2 ( int  streak,
float  dec,
const float  step[2],
float  stride 
)
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::ghostPass0 ( const float *  ghost_modulation1st)
protectedvirtual

ghost image passes

virtual void makVrv::DtHdrDrawableRenderData::ghostPass1 ( const float *  ghost_modulation2nd)
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::gaussianBlurComposePass ( void  )
protectedvirtual

final passes

virtual void makVrv::DtHdrDrawableRenderData::starStreakCompose ( void  )
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::finalGlarePass ( void  )
protectedvirtual
virtual void makVrv::DtHdrDrawableRenderData::initializeUniformLocations ( HDR_PASS  pass)
protectedvirtual

init uniform locations from the compiled shader

virtual void makVrv::DtHdrDrawableRenderData::zeroOutUniformLocations ( )
protectedvirtual

set initial value of uniform locations to an invalid value

virtual void makVrv::DtHdrDrawableRenderData::createToneMappingProgramIfNecessary ( void  )
protectedvirtual

create the tone mapping program if not created already

virtual void makVrv::DtHdrDrawableRenderData::slot_hdrResolutionScaleChanged ( int  val)
protectedvirtual

Trigger shader recompile if resolution scale has changed.

Member Data Documentation

friend makVrv::DtHdrDrawableRenderData::DtHdrDrawableRenderDataCreator

only friend can create

DtDe& makVrv::DtHdrDrawableRenderData::myDe
protected
const DtHdrOptions& makVrv::DtHdrDrawableRenderData::myOptions
protected
float makVrv::DtHdrDrawableRenderData::myAspectRatio
protected
std::array<DtGlProgram*, PROGSIZE> makVrv::DtHdrDrawableRenderData::myShaders
protected
float makVrv::DtHdrDrawableRenderData::myStarModulation1st[16]
protected
float makVrv::DtHdrDrawableRenderData::myStarModulation2nd[16]
protected
float makVrv::DtHdrDrawableRenderData::myStarModulation3rd[16]
protected
float makVrv::DtHdrDrawableRenderData::myFilmicGhostModulation1st[16]
protected
float makVrv::DtHdrDrawableRenderData::myFilmicGhostModulation2nd[16]
protected
float makVrv::DtHdrDrawableRenderData::myCameraGhostModulation1st[16]
protected
float makVrv::DtHdrDrawableRenderData::myCameraGhostModulation2nd[16]
protected
float makVrv::DtHdrDrawableRenderData::myHoriModulation1st[16]
protected
float makVrv::DtHdrDrawableRenderData::myHoriModulation2nd[16]
protected
float makVrv::DtHdrDrawableRenderData::myHoriModulation3rd[16]
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myComposebuffer[LEVEL_TOTAL]
protected

mutables needed since osg drawable draw implementations are const functions. This allows us to keep track of a bit of state that is needed between frames Also these are protected instead of private because they may be needed by classes derived from this class

Render textures need to be initialized in draw implementation so they need to be mutable...

DtGlTexture* makVrv::DtHdrDrawableRenderData::myBlurbufferA[LEVEL_TOTAL]
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myBlurbufferB[LEVEL_TOTAL]
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myStreakbufferA[8]
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myStreakbufferB[8]
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myStreakbufferFinal
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myGhost1stBuffer
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myGhost2ndBuffer
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myGlareBuffer
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myLumcurrent
protected
unsigned int makVrv::DtHdrDrawableRenderData::myLumNextBuffer
protected
const float* makVrv::DtHdrDrawableRenderData::myLumNextBufferPtr
protected
DtGlTexture* makVrv::DtHdrDrawableRenderData::myInitialBuffer
protected
double makVrv::DtHdrDrawableRenderData::myLastAdpativeLumFrameTime
protected

need to keep track of the previous frame time in draw implementation so this needs to be mutable.

int makVrv::DtHdrDrawableRenderData::myExtractHlTresholdAndScalarLoc
protected

locations of various uniforms in the shaders

int makVrv::DtHdrDrawableRenderData::myStarStreakStepSizeAndStrideLoc
protected
int makVrv::DtHdrDrawableRenderData::myStarStreakColorCoeffLoc
protected
int makVrv::DtHdrDrawableRenderData::myGhostImageScalarLoc
protected
int makVrv::DtHdrDrawableRenderData::myGhostImageColorCoeffLoc
protected
int makVrv::DtHdrDrawableRenderData::myGaussianBlurComposeCoeffLoc
protected
int makVrv::DtHdrDrawableRenderData::myStarStreakComposeNumSamplersLoc
protected
int makVrv::DtHdrDrawableRenderData::myFinalGlarecomposeMixCoeffLoc
protected
int makVrv::DtHdrDrawableRenderData::myElapsedTimeLoc
protected
int makVrv::DtHdrDrawableRenderData::mySceneTexLoc
protected
int makVrv::DtHdrDrawableRenderData::myBlurTexLoc
protected
int makVrv::DtHdrDrawableRenderData::myScalesBlurTexLuminanceSaturationLoc
protected
int makVrv::DtHdrDrawableRenderData::myBlurAmountGammaEnablePassThroughLoc
protected
float makVrv::DtHdrDrawableRenderData::myLastLuminanceValue
protected
double makVrv::DtHdrDrawableRenderData::myLastHdrFrameTime = -1
protected
DtHdrDrawable* makVrv::DtHdrDrawableRenderData::myParent = nullptr
protected
DtSignalConnectionManager makVrv::DtHdrDrawableRenderData::myConnections
protected
osg::ref_ptr<osg::Texture> makVrv::DtHdrDrawableRenderData::myLensMask
protected
osg::ref_ptr<osg::Texture> makVrv::DtHdrDrawableRenderData::myInputTex
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)