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

Miscellaneous shader utilities for osg.

Classes

struct  CachedUniformData
 

Static Public Member Functions

static void bindAttributes (const osg::GLExtensions *ext, const osg::StateSet *ss, int shader, int contextID)
 
static bool getVPShaderVector (osg::StateSet *ss, osg::State &state, unsigned int &shaderHash, std::vector< unsigned int > &vertShaderVector, std::vector< unsigned int > &fragShaderVector, bool skip_shadow_shaders=false, bool skip_multiview_shaders=false)
 
static bool addDegenerateShadersIfNeeded (osg::StateSet *ss, osg::State &state, std::vector< unsigned int > &vertShaderVector, std::vector< unsigned int > &fragShaderVector, bool skip_shadow_shaders=false)
 
static void restoreEverything (osg::State &state)
 
static void restoreOpenGLMode (const osg::State &state, int stateToSet)
 
static void restoreOpenGLStateAttribute (osg::State &state, osg::StateAttribute::Type type)
 
static void restoreOpenGLProgram (const osg::State &state)
 
static void restoreOpenGLFBO (const osg::State &state)
 
static void markAllTextureAttributesDirty (osg::State &state)
 
static void generateModelInstanceShaders (osg::Node *node, const std::string &shaderName)
 
static unsigned getNumGPUTextureImageUnits ()
 
static void clearCachedProgramsAndUniformLocations (void)
 

Protected Types

typedef std::unordered_map
< unsigned int,
CachedUniformData
UniformLocationMap
 
typedef std::unordered_map
< int, UniformLocationMap
ShaderUniLocMap
 

Static Protected Attributes

static ShaderUniLocMap theShaderUniLocMap
 

Private Member Functions

 DtOsgShaderUtils ()=delete
 
 DtOsgShaderUtils (const DtOsgShaderUtils &rhs)=delete
 
DtOsgShaderUtilsoperator= (const DtOsgShaderUtils &rhs)=delete
 
virtual ~DtOsgShaderUtils ()=delete
 

Member Typedef Documentation

typedef std::unordered_map<int, UniformLocationMap> makVrv::DtOsgShaderUtils::ShaderUniLocMap
protected

Constructor & Destructor Documentation

makVrv::DtOsgShaderUtils::DtOsgShaderUtils ( )
privatedelete

not allowed

makVrv::DtOsgShaderUtils::DtOsgShaderUtils ( const DtOsgShaderUtils rhs)
privatedelete

not allowed

virtual makVrv::DtOsgShaderUtils::~DtOsgShaderUtils ( )
privatevirtualdelete

not allowed

Member Function Documentation

DtOsgShaderUtils& makVrv::DtOsgShaderUtils::operator= ( const DtOsgShaderUtils rhs)
privatedelete

not allowed

static void makVrv::DtOsgShaderUtils::bindAttributes ( const osg::GLExtensions *  ext,
const osg::StateSet *  ss,
int  shader,
int  contextID 
)
static

Loop over the uniforms of the stateset of the node and attach them to the current opengl active shader. Also loops over the texture attributes in the stateset and attaches those as well always send is used by speedtree due to bug in updating uniform.

static bool makVrv::DtOsgShaderUtils::getVPShaderVector ( osg::StateSet *  ss,
osg::State &  state,
unsigned int shaderHash,
std::vector< unsigned int > &  vertShaderVector,
std::vector< unsigned int > &  fragShaderVector,
bool  skip_shadow_shaders = false,
bool  skip_multiview_shaders = false 
)
static

Collect all the active osg::Shader objects in the provided State and compile them. If they compile they are pushed onto shaderVector. shaderVector is cleared in this function so only the shaders from the State are kept. The stateset "ss" is then cleared of an update mark. Returns True if the ss was marked for an update and the shaderVector was modified.

static bool makVrv::DtOsgShaderUtils::addDegenerateShadersIfNeeded ( osg::StateSet *  ss,
osg::State &  state,
std::vector< unsigned int > &  vertShaderVector,
std::vector< unsigned int > &  fragShaderVector,
bool  skip_shadow_shaders = false 
)
static

adds a degenerate shadow shader

static void makVrv::DtOsgShaderUtils::restoreEverything ( osg::State &  state)
static
static void makVrv::DtOsgShaderUtils::restoreOpenGLMode ( const osg::State &  state,
int  stateToSet 
)
static

restore the OpenGL mode of the state

static void makVrv::DtOsgShaderUtils::restoreOpenGLStateAttribute ( osg::State &  state,
osg::StateAttribute::Type  type 
)
static

restore the OpenGL state attribute

static void makVrv::DtOsgShaderUtils::restoreOpenGLProgram ( const osg::State &  state)
static

restore the OpenGL program

static void makVrv::DtOsgShaderUtils::restoreOpenGLFBO ( const osg::State &  state)
static

restore the OpenGL fbo

static void makVrv::DtOsgShaderUtils::markAllTextureAttributesDirty ( osg::State &  state)
static

mark dirty

static void makVrv::DtOsgShaderUtils::generateModelInstanceShaders ( osg::Node *  node,
const std::string &  shaderName 
)
static

utility function for generating shaders for vrvOsg model instances simpler than the DtOsgShaderManager::generateShaders in that it doesn't share the statesets and just runs the osgEarth::ShaderGenerator on the node. This was created solely for the purpose of removing duplicate code for model instances to setup their shaders.

static unsigned makVrv::DtOsgShaderUtils::getNumGPUTextureImageUnits ( )
static

Query the number of available texture image units for shader samplers.

static void makVrv::DtOsgShaderUtils::clearCachedProgramsAndUniformLocations ( void  )
static

delete the entries of programs to cached uniform locations must call when cloud layers are deleted, atmosphere deleted, triton drawable cleaned up.

Member Data Documentation

ShaderUniLocMap makVrv::DtOsgShaderUtils::theShaderUniLocMap
staticprotected

used to cache the shader uniform locations to avoid glGetUniformLocation calls Saves somewhere between 1-3ms and reduces variability of frame time with Triton and Silverlining Tried caching the uniform values as well but that did not seem to make a difference.


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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)