HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Shader Class Referenceabstract

#include <RE_Shader.h>

+ Inheritance diagram for RE_Shader:

Classes

class  Factory
 
class  re_LibFunc
 
struct  re_NeededLibFuncs
 

Public Types

enum  { USE_GLSL_BASE_VERSION = -1, USE_SHADER_GLSL_VERSION = 0 }
 

Public Member Functions

 RE_Shader (const char *program_name, int shader_version)
 
virtual ~RE_Shader ()
 
exint getUniqueID () const
 
virtual int64 getMemoryUsage (bool inclusive) const
 
void setRegisterProgram (bool register_program)
 
const char * getName () const
 Readable name of the shader. More...
 
const char * getDefines () const
 Any define commands used to alter this shader. More...
 
int getProgram () const
 Raw GL id of the shader. More...
 
bool isLinked () const
 True if the shader has been successfully linked. More...
 
int getCodeVersion () const
 Returns the version of the shader (110,120,130,140,150,330,400,410). More...
 
virtual RE_ShaderStagenewShader (RE_ShaderType type, const char *name=0)=0
 
void useHoudiniLibraryFuncs ()
 If true, this shader may use Houdini's builtin functions. More...
 
void useDefaultAttribMap (bool enable=true)
 If true, this shader follows the default Houdini attribute map. More...
 
void useExplicitAttribMap (bool enable=true)
 
virtual bool attachShader (RE_Render *r, RE_ShaderStage *obj, UT_String *messages=nullptr)
 
virtual bool detachShader (RE_Render *r, RE_ShaderStage *obj)
 
RE_ShaderStagegetShader (const char *shader_name, RE_ShaderType hint=RE_SHADER_ALL)
 Returns an attached shader by the given name. More...
 
virtual bool setVertexInput (RE_Render *r, const char *name, int vertex_index)
 
virtual bool setFragmentOutput (RE_Render *r, const char *name, int buffer_index)
 
virtual bool linkShaders (RE_Render *r, UT_String *messages=nullptr)
 
int getLinkSerial () const
 Bumped every time a link is performed (uniforms invalidated, etc). More...
 
virtual bool validateShader (RE_Render *r, UT_String *messages=nullptr)
 
virtual void clearShaders (RE_Render *r, RE_ShaderType types=RE_SHADER_ALL)
 Clears and deletes all the shader objects of a certain type (or all) More...
 
bool hasShader (RE_ShaderType type) const
 
void disableShadingRate ()
 
virtual RE_TextureDimension getTextureMapType (RE_Render *r, const UT_StringHolder &name)=0
 Return the texture type for the sampler named 'name'. More...
 
int getNumTextures () const
 Return the number of samplers this shader references. More...
 
int getNumImages () const
 
const char * getTextureSamplerName (int tex_index) const
 Return the name of a sampler uniform Return the texture sampler name of the enumerated samplers at 'tex_index' Must be within [0, getNumTextures()-1]. More...
 
RE_TextureDimension getTextureSamplerType (int tex_index) const
 Return the texture sampler type at 'tex_index' [0, getNumTextures()-1]. More...
 
UT_StringHolder findSamplerAtUnit (int tex_unit) const
 
int getUniformTextureUnit (const UT_StringHolder &uniform_name, int array_index=0) const
 return the texture unit of sampler 'uniform_name' Return the texture unit this sampler has been assigned to, or -1 if 'uniform_name' does not exist, or is not a sampler. array_index is used to identify indices of sampler arrays. More...
 
bool setUniformTextureUnit (RE_Render *r, const UT_StringHolder &uniform_name, int unit_index)
 Set a binding point for the given sampler. More...
 
int getUniformImageUnit (const UT_StringHolder &uniform_name) const
 return the image unit of sampler 'uniform_name' Return the image unit this image uniform has been assigned to, or -1 if 'uniform_name' does not exist, or is not a image uniform. Images are different than textures, used by RE_EXT_IMAGE_LOAD_STORE (GL4.2). More...
 
RE_UniformType getUniformType (const UT_StringHolder &uniform_name) const
 
int getNumUniforms () const
 Returns the number of active uniforms in this shader. More...
 
const char * getUniformName (int idx) const
 Returns the name of active uniform 'idx' [0, getNumUniforms()-1]. More...
 
int getUniformLocation (int idx) const
 Return the GL uniform location of uniform 'idx' [0, getNumUniforms()-1]. More...
 
RE_UniformType getUniformType (int idx) const
 Return the GL uniform type 'idx' [ 0, getNumUniforms()-1]. More...
 
int getBlockIndexForUniform (int idx) const
 Return the index of the uniform block a uniform is in, -1 for none. More...
 
virtual bool bindImage (RE_Render *r, const UT_StringHolder &name, RE_Texture *image, RE_BufferAccess image_access)=0
 
virtual bool bindImageLayer (RE_Render *r, const UT_StringHolder &name, RE_Texture *image, RE_BufferAccess image_access, int layer)=0
 
bool setTextureHandle (RE_Render *r, const UT_StringHolder &uniform_name, RE_Texture *texture, int *saved_idx=0)
 
bool clearTextureHandle (RE_Render *r, const UT_StringHolder &uniform_name, int *saved_idx=0)
 Remove a bindless handle from the uniform, clearing it to 0 (no tex). More...
 
virtual bool bindUniform (RE_Render *r, const RE_Uniform *uniform, int index=-1)
 Bind an RE_Uniform's values to the corresponding GL uniform Bind an RE_Uniform to this shader. If 'uniform' is an array uniform then 'index' specifies which array element to bind. 'index' must be less than uniform->getSize(). Pass -1 for 'index' (the default) to bind all elements of an array; passing -1 for non-arrays is safe and is equivalent to passing 0. More...
 
bool hasUniform (const UT_StringHolder &uniform_name) const
 returns true if the named uniform exists in the shader. More...
 
bool hasBuiltInUniform (RE_UniformBuiltIn uniform) const
 Queries the use of a builtin uniform Returns true if this shader has the specified built-in uniform. 'uniform' must be an RE_UniformBuiltIn. Note that certain built-in uniforms may only be supported for certain languages. More...
 
const UT_IntArraygetBuiltInUniformList () const
 Returns a list of RE_UniformBuiltIn IDs this shader uses. More...
 
void bindBuiltIns (RE_Render *r, bool force_update=false)
 Bind all builtin uniforms. Bind all builtin uniforms this shader uses to their current values in RE_Render. More...
 
void invalidateUniform (RE_UniformBuiltIn uniform)
 
virtual void printUniforms (RE_Render *r, std::ostream *os=nullptr) const
 Prints all the active uniforms plus their values to stream os (or cerr) More...
 
virtual int getMaxUniformBlocks (RE_Render *)
 Returns the OpenGL maximum number of supported blocks. More...
 
virtual int getMaxUniformBlockSizeB (RE_Render *)
 Returns the OpenGL maximum size of a uniform block, in bytes. More...
 
virtual int getNumUniformBlocks () const
 Returns the number of blocks and specific uniform blocks. More...
 
virtual RE_UniformBlockHandle getUniformBlock (int) const
 Return an attached uniform block by index. More...
 
virtual RE_UniformBlockHandle getUniformBlock (const char *name) const
 Return an attached uniform block by name. More...
 
virtual int getUniformBlockIndex (const char *name) const
 Returns the block binding point of the named block. More...
 
virtual bool attachUniformBlock (RE_UniformBlock *)
 Attach an RE_UniformBlock to this shader Attach a single uniform block to the shader. The shader owns the block while attached, and will delete it if the shader is deleted, or may delete it if linkShaders() is called and it is no longer in use. If you want to cache a block, detach it when you're done with the shader. If a block with the same name is already attached to this shader, it will be deleted. More...
 
virtual RE_UniformBlockHandle detachUniformBlock (const char *)
 Detach a named RE_UniformBlock from this shader Detach a single uniform block by name or pointer. The shader will no longer keep a reference to it, and will not delete it when relinking or when the shader is deleted. Note that a shader must have all blocks attached when executed. Detaching a uniform block does not remove the GL binding to the block, it merely removes this shader's ownership of the block (for performance reasons) More...
 
virtual bool detachUniformBlock (RE_UniformBlock *)
 Detach a specific RE_UniformBlock from this shader. More...
 
virtual bool detachAllUniformBlocks ()
 Detaches all blocks referenced by this shader. More...
 
virtual bool bindAllUniformBlocks (RE_Render *)
 
virtual bool initUniformBlock (RE_Render *r, RE_UniformBlock *block, int index=-1) const
 Initialize a uniform block based on this shader's block layout Initializes a uniform block with the proper offsets and size for block index 'index'. If index is -1, block must have the name of one of the uniform blocks in the shader. More...
 
virtual RE_UniformBlockHandle copyUniformBlock (const char *name, bool data_too) const
 Copies the structure of the named uniform block, and possibly the data. More...
 
virtual bool updateUniformBlock (const RE_UniformBlockHandle &b) const
 
virtual int overrideUniformBlock (RE_UniformBlock *block, int block_index=-1)
 
virtual void removeOverrideBlock (int)
 Remove an override block from the shader, by index. More...
 
virtual void removeOverrideBlock (RE_UniformBlock *b)
 Remove a specific override block from the shader. More...
 
virtual void removeOverrideBlocks ()
 Remove all override blocks from the shader. More...
 
virtual RE_UniformBlockHandle getOverrideBlock (int) const
 Return the currently bound override block for an index, if any is bound. More...
 
virtual RE_UniformBlockHandle createStorageBlock (const char *name, int array_size)
 
virtual RE_UniformBlockHandle getStorageBlock (const char *name)
 Return the block definition for storage block 'name'. More...
 
virtual RE_UniformBlockHandle getStorageBlockBinding (const char *name)
 Return the storage block bound to 'name' (bound by attachStorageBlock) More...
 
virtual RE_VertexArraygetStorageBufferBinding (const char *name)
 Return the raw buffer bound to 'name' (bound by attachStorageBlock) More...
 
virtual bool attachStorageBlock (const RE_UniformBlockHandle &block)
 
virtual bool detachStorageBlock (const RE_UniformBlockHandle &block)
 
virtual bool attachStorageBuffer (RE_VertexArray *raw_buffer)
 
virtual bool detachStorageBuffer (RE_VertexArray *raw_buffer)
 
virtual bool detachStorageBinding (const char *bind_name)
 Unbind the block or buffer attached to binding point 'bind_name'. More...
 
bool hasShaderAttribs () const
 Return if the vertex shader has input attributes. More...
 
int getNumShaderAttribs () const
 Return the number of vertex shader input attributes. More...
 
bool hasTessellation () const
 
const char * getShaderAttribName (int i) const
 Return the name of vertex shader input at index 'i'. More...
 
RE_GenericAttribID getShaderAttribGenID (int i) const
 
int getShaderAttribLocation (int i) const
 Return the GL attribute location of vertex shader input at index 'i'. More...
 
RE_GPUType getShaderAttribType (int i) const
 Return the type of vertex shader input at index 'i'. More...
 
int getShaderAttribSize (int i) const
 Return the vector size of vertex shader input at index 'i'. More...
 
const UT_StringListgetShaderAttribNames () const
 Return a string array of all vertex shader input names. More...
 
const UT_IntArraygetShaderAttribLocations () const
 Return an int array of all vertex shader input locations. More...
 
const UT_IntArraygetShaderAttribSizes () const
 Return an int array of all vertex shader input sizes. More...
 
const char * getAttribNameForLocation (int loc) const
 Returns the name of a vertex shader input at GL location 'loc'. More...
 
int getAttributeModeLoc (RE_GenericAttribID t) const
 Return the default GL location of generic vertex attribute 't'. More...
 
int getAttributeSamplerLoc (RE_GenericAttribID t) const
 Return the texture sampler unit of a texture buffer object for 't'. More...
 
int getNumBuiltinAttribs () const
 Return the number of GL-builtin vertex shader inputs (gl_Vertex, gl_*) More...
 
const char * getBuiltinAttrib (int i) const
 Return the name of GL-builtin vertex shader input at index 'i'. More...
 
int getNumBufferAttribs () const
 Return the number of texture-buffer object attributes. More...
 
const char * getBufferAttrib (int i) const
 Return the name of texture-buffer object attribute at index 'i'. More...
 
RE_GenericAttribID getBufferAttribID (int i) const
 
int getNumBufferTextures () const
 Return the number of texture buffer object samplers in this shader. More...
 
const char * getBufferTextureName (int i) const
 Name of the texture buffer object sampler at index 'i'. More...
 
RE_GPUType getBufferTextureType (int i) const
 Type of the texture buffer object sampler at index 'i' (float, int, uint) More...
 
bool hasBufferTexture (const char *name) const
 True if the shader has a texture buffer object sampler named 'name'. More...
 
bool getAttribute (const char *attrib_name, int &location, RE_GPUType &type, int &size) const
 Return information about vertex shader input 'attrib_name' Returns the location and size of the named vertex attribute, or false if it does not exist in this shader. This also includes the GL built-ins, though these will not set location type, or size; only return true/false for their presence in the shader. More...
 
bool hasAttribute (const char *attrib_name) const
 Simpler version of getAttribute() - just returns if the attribute exists. More...
 
bool getAttributeIndex (int index, UT_String &name, int &location, RE_GPUType &type, int &size) const
 Return information about vertex shader input at 'index' Similar to getAttribute(), but the name of the input does not need to be known. GL builtins are not supported by this method. index must be within [0, getNumAttribs()-1]. More...
 
void printAttributes (std::ostream *os=nullptr) const
 
bool bindZeroConstant (RE_Render *r, RE_VertexArray *array)
 Zero out the constant attribute location given by 'array' Bind a constant zero for this array. If data is non-nullptr, this data is used, otherwise the current constant data for this array is used (default 0's). More...
 
virtual void loadShaderTexMaps (RE_Render *)=0
 Loads texture maps specified by the RE_TextureMap bindTextureMap() More...
 
virtual void loadBoundTextures (RE_Render *r)=0
 
virtual void unloadBoundTextures (RE_Render *r)=0
 
int getNumTextures (RE_ShaderType stage) const
 
void getShaderSource (RE_Render *r, UT_String &source, RE_ShaderType sh=RE_SHADER_ALL)
 Returns the shader source of some or all attached shaders. More...
 
bool prepForDrawing (RE_Render *r, RE_Geometry *obj=nullptr, RE_ElementArray *element=nullptr, RE_VertexState *state=nullptr, unsigned int vertex_stride=0, RE_OverrideList *atrbover=0, int instance_group=0)
 Prepare this shader for rendering Binds uniform buffer objects and all builtin uniforms. Optionally re-binds vertex attribute locations in 'obj'. More...
 
bool cleanupAfterDrawing (RE_Render *r, RE_Geometry *obj=nullptr, RE_VertexState *vstate=nullptr, RE_OverrideList *atrbover=0)
 
virtual bool runCompute (RE_Render *r, int num_wg_x, int num_wg_y=1, int num_wg_z=1)
 COMPUTE. More...
 
virtual bool runCompute (RE_Render *r, RE_VertexArray *wg_buffer, int offset)
 
virtual void applyShader (RE_Render *r, bool update_re=true)=0
 
virtual void removeShader (RE_Render *r, bool update_re=true)=0
 
virtual void cleanup (RE_Render *r)=0
 
RE_ShaderStageloadShader (RE_Render *r, RE_ShaderType stype, const char *filename, UT_String *messages=nullptr, const char *shader_name=nullptr, const char *defines="", int default_code_version=USE_GLSL_BASE_VERSION, int geom_max_verts=-1, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL, bool print_source=true)
 
RE_ShaderStageaddShader (RE_Render *r, RE_ShaderType stype, const char *shader_source, const char *shader_name, int codeversion, UT_String *messages=nullptr, bool print_source=true, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL, bool preprocess=false)
 
Geometry Shaders

Geometry shaders must be initialized with a cap on how many vertices they emit per primitive, as well as the primitives they operate on, and the primitives they produce. A vertex and fragment shader MUST be used with a geometry shader. A geometry shader will fail if the primitives drawn do not match the geometry shader input. Input primitives can be points, line variants (lines, line loop, line strip) or triangle variants (tris, tristrips, trifans). Quads and polys are not supported. The output must be points, linestrip or tristrip.

virtual bool setGeometryParms (RE_Render *r, int max_vertices, RE_PrimType input, RE_PrimType output)
 Specify geometry shader parameters. More...
 
void getGeometryParms (int &maxverts, RE_PrimType &input_type, RE_PrimType &output_type) const
 Fetch current geometry shader values. Return the geometry shader parameters specified by setGeometryParms() or the shader itself (via layout(in=triangles), etc). More...
 
void setShadingRate (fpreal rate)
 
fpreal getShadingRate () const
 
bool isSampleShading () const
 
bool bindInt (RE_Render *r, const UT_StringHolder &name, int v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindFloat (RE_Render *r, const UT_StringHolder &name, float v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindDouble (RE_Render *r, const UT_StringHolder &name, double v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindColor (RE_Render *r, const UT_StringHolder &name, const UT_Color &c)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindColor (RE_Render *r, const UT_StringHolder &name, const UT_Color &c, fpreal alpha)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector2F &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector3F &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector4F &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector2D &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector3D &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector4D &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector2i &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector3i &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVector (RE_Render *r, const UT_StringHolder &name, const UT_Vector4i &v)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector2FArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector3FArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector4FArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector2DArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector3DArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindVectors (RE_Render *r, const UT_StringHolder &name, const UT_Vector4DArray &vals)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix2F &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix3F &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix4F &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix2D &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix3D &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
bool bindMatrix (RE_Render *r, const UT_StringHolder &name, const UT_Matrix4D &m)
 Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type. More...
 
virtual bool bindTextureMap (RE_Render *r, const UT_StringHolder &name, const char *mapname, const char *relative_to)=0
 
Setting Uniforms

These methods set uniform values in a shader. 'name' is the name of the uniform in the shader. 'val' is the value that uniform should take. 'array_size' is used if the uniform is an array. 'saved_idx' is an optimization to speed up subsequent accesses to the uniforms. Initially it should be -1.

virtual bool bindVariableInt (RE_Render *r, const UT_StringHolder &name, const int *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariableInt2 (RE_Render *r, const UT_StringHolder &name, const int *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer vector-2. More...
 
virtual bool bindVariableInt3 (RE_Render *r, const UT_StringHolder &name, const int *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer vector-3. More...
 
virtual bool bindVariableInt4 (RE_Render *r, const UT_StringHolder &name, const int *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer vector-4. More...
 
virtual bool bindUint64 (RE_Render *r, const UT_StringHolder &name, uint64 *val, int array_size=1, int *saved_idx=0)=0
 64b Integer handle for bindless texturing More...
 
virtual bool bindVariable1 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable2 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable3 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable4 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable1 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable2 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable3 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindVariable4 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix2 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix3 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix4 (RE_Render *r, const UT_StringHolder &name, const fpreal32 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix2 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix3 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindMatrix4 (RE_Render *r, const UT_StringHolder &name, const fpreal64 *val, int array_size=1, int *saved_idx=0)=0
 Generic Integer scalar. More...
 
virtual bool bindTexture (RE_Render *r, const UT_StringHolder &name, RE_Texture *tex, int *saved_idx=0)=0
 
RE_TextureCompress getTextureFormat () const
 Override texture compression for texture bound via bindTextureMap() More...
 
void setTextureFormat (RE_TextureCompress format)
 Override texture compression for texture bound via bindTextureMap() More...
 
void limitTextureSize (bool limit, int w, int h)
 Limit the resolution of the textures to a max width and height. More...
 
bool limitTextureSize () const
 Limit the resolution of the textures to a max width and height. More...
 
int getMaxTextureWidth () const
 Limit the resolution of the textures to a max width and height. More...
 
int getMaxTextureHeight () const
 Limit the resolution of the textures to a max width and height. More...
 
void setTextureScale (float sc)
 Scale by a constant scale factor for textures bound via bindTextureMap() More...
 
float getTextureScale () const
 Scale by a constant scale factor for textures bound via bindTextureMap() More...
 
bool mipMapTextures () const
 Enable or disable mipmapping for textures bound via bindTextureMap() More...
 
void mipMapTextures (bool yes)
 Enable or disable mipmapping for textures bound via bindTextureMap() More...
 
void setAnisotropySamples (int samples)
 Set anisotropic filtering for textures bound via bindTextureMap() More...
 
int getAnisotropySamples () const
 Set anisotropic filtering for textures bound via bindTextureMap() More...
 
bool matchesLights (int light_serial, int light_id) const
 Cached RE_LightList information (uniform blocks) More...
 
void setLightID (int light_serial, int light_id, int mask)
 Cached RE_LightList information (uniform blocks) More...
 
int getLightMask () const
 Cached RE_LightList information (uniform blocks) More...
 

Static Public Member Functions

static RE_Shadercreate (const char *name, int shader_version=0, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL, RE_Shader::Factory *factory=nullptr)
 
static RE_ShadercreateShader (RE_Render *r, const char *name, const char **shader_files, int shader_version=USE_SHADER_GLSL_VERSION, UT_String *compile_msg=nullptr, bool use_houdini_libs=true, RE_ShaderLanguage s=RE_SHADER_LANGUAGE_GLSL, bool register_program=true, const char *extra_defines=nullptr, RE_Shader::Factory *factory=nullptr, bool dump_src_on_error=true)
 
static RE_ShadercreateShader (RE_Render *r, const char *name, const char *shader_files, int shader_version=USE_SHADER_GLSL_VERSION, UT_String *compile_msg=nullptr, bool use_houdini_libs=true, RE_ShaderLanguage s=RE_SHADER_LANGUAGE_GLSL, bool register_program=true, const char *extra_defines=nullptr, RE_Shader::Factory *factory=nullptr, bool dump_src_on_error=true)
 A version with a single string containing whitespace-separated filenames. More...
 
static RE_ShaderlookupProgram (int id)
 
static int getBaseGLSLVersion ()
 Returns the minimum GLSL version supported (base requirement) More...
 
static int getBaseGLSLVersion (RE_ShaderLanguage lang)
 Returns the minimum GLSL version supported for specific language type. More...
 
static int determineCodeVersion (const char *shader_string)
 
static RE_ShadergetShader (int program_object)
 Fetch a shader based on GL program id Returns the RE_Shader object with the specified program object if it exists; otherwise, returns nullptr. More...
 
static bool loadFile (const char *filename, const char *defines, UT_WorkBuffer &src, int &codeversion, UT_String *messages, int default_code_version=0, int max_verts=-1, bool adjust_line_num=false, bool loadingInclude=false, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL)
 
static bool getCodeBlock (const char *block_name, UT_StringHolder &block_source, RE_ShaderLanguage lang)
 
static void unregisterProgram (int program_object)
 
static void removeAllTextureRefs (RE_OGLTexture *)
 
static int loadProgramFile (RE_Render *r, const char *file, const char *basepath, UT_String &prog_name, UT_StringArray &files, UT_StringArray &files_names, UT_StringArray &inputs, UT_StringArray &outputs, UT_StringArray &defines, int &codeversion, fpreal &shading_rate, int &max_verts, bool &use_attrib_map, bool &explicit_attrib_map, int max_version, RE_ShaderLanguage &shader_lang, UT_String *msg)
 

Protected Member Functions

virtual void removeTextureRefs (RE_OGLTexture *)
 
virtual int getAttributeIndex (const char *name) const
 
int getUniformIndex (const UT_StringHolder &name) const
 
bool loadHoudiniLibraryFuncs (RE_Render *r, UT_String *msg, RE_ShaderLanguage lang)
 
const char ** getTransformFeedbackAttribs (int &num_attribs)
 
virtual re_LibFuncgetShaderLibrary () const
 
void setGeomMaxVerts (int max_verts)
 

Static Protected Member Functions

static void registerProgram (RE_Shader *shader, int program_object)
 
static RE_TexturegetDefaultTBO (RE_Render *r)
 
static void scanSourceForFuncs (const char *line, RE_ShaderType shtype, UT_Array< re_NeededLibFuncs > &needed, re_LibFunc *library, int glmajor, int glminor)
 
static void processCodeLine (const char *line, int line_num, const char *defines, UT_WorkBuffer &src, int &codeversion, UT_String *messages, int default_code_version, bool &found_codeversion, int max_verts, bool adjust_line_num, RE_ShaderLanguage lang)
 

Protected Attributes

UT_String myProgramName
 
UT_String myExtraDefines
 
int myProgramObject
 
bool myLinkedFlag
 
bool myUseDefaultAttribMap
 
bool myUseExplicitAttribMap
 
bool myRegisterProgram
 
RE_TextureCompress myTexFormat
 
bool myLimitTextureSize
 
int myMaxTexW
 
int myMaxTexH
 
float myTextureScale
 
bool myMipMapTexture
 
int myTextureAnisotropy
 
UT_ValArray< RE_ShaderStage * > myVertexShaders
 
UT_ValArray< RE_ShaderStage * > myTessControlShaders
 
UT_ValArray< RE_ShaderStage * > myTessEvalShaders
 
UT_ValArray< RE_ShaderStage * > myGeometryShaders
 
UT_ValArray< RE_ShaderStage * > myFragmentShaders
 
UT_ValArray< RE_ShaderStage * > myComputeShaders
 
UT_IntArray myNumTexturesPerStage
 
int myGeoShaderMaxVertices
 
RE_PrimType myGeoShaderInputPrims
 
RE_PrimType myGeoShaderOutputPrims
 
UT_StringList myBuiltInAttribNames
 
UT_StringList myAttribNames
 
UT_StringList myBufferAttribNames
 
UT_Array< RE_GenericAttribIDmyBufferAttribGenIDs
 
UT_IntArray myAttribLocations
 
UT_Array< RE_GenericAttribIDmyAttribGenIDs
 
UT_Array< RE_GPUTypemyAttribTypes
 
UT_IntArray myAttribSizes
 
UT_StringList myFeedbackNames
 
UT_ValArray< RE_UniformData * > myUniforms
 
UT_IntArray myBuiltInUniforms
 
UT_IntArray myBuiltInVersion
 
UT_ValArray< const RE_Uniform * > myBuiltInLastUniform
 
UT_SymbolMap< intmyUniformTable
 
UT_SymbolMap< intmyUniformBlockTable
 
UT_IntArray myAttrModeLocs
 
UT_IntArray myAttrSamplerLocs
 
int myBuiltInMap [RE_UNIFORM_BUILT_IN__count]
 
int64 myBuiltInUniformSerial
 
int64 myRenderSerial
 
RE_VertexMapmyVertexMap
 
UT_IntArray myBufferTextures
 
UT_Array< re_NeededLibFuncs > * myNeededLibraryFuncs
 
int myCodeVersion
 
RE_GeometrymyTransformFeedbackGeometry
 
bool myTransformFeedbackGeometryOwned
 
UT_ValArray< re_VertexName * > myTransformFeedbackVertices
 
fpreal myShadingRate
 
UT_IntArray myTextureUniforms
 
UT_IntArray myImageUniforms
 
int myShaderSerial
 
int myLightsSerial
 
int myLightsId
 
int myLightMask
 
exint myUniqueID
 
UT_IntArray myDrawBoundTextures
 
UT_WorkBuffer myWorkBuffer
 

Transform Feedback

Using transform feedback, it is possible to capture vertex or geometry shader outputs and write these values to buffers (RE_VertexArrays). Method to add or remove shader outputs should be called before the shader is linked, otherwise they will cause a re-link of the shader. Note that relinking with clear out any uniform values, so these buffers should be set up early.

void addCaptureGeometry (RE_Geometry *object, bool give_ownership=false)
 Specify an RE_Geometry to collect data from Transform Feedback. Specify a geometry object to hold all the arrays for transform feedback. You retain ownership of the object unless 'give_ownership' is true. If no object is attached when the shader is linked, one will be created for you (with ownership maintained by this shader). More...
 
RE_GeometrygetCaptureGeometry (bool take_ownership=false)
 Return the capture geometry for transform feedback. More...
 
bool addFeedbackBuffer (const char *attrib_name)
 Specify a generic attribute to capture during transform feedback. More...
 
bool removeFeedbackBuffer (const char *attrib_name)
 Remove a generic attribute from the capture geometry. More...
 
void setFeedbackBufferSize (int num_vertices)
 Will generate a new owned capture geometry if one isn't present. More...
 
void clearAllFeedbackBuffers ()
 Remove all attributes from the capture gemetry. More...
 
bool hasTransformFeedback () const
 True if this shader has transform feedback varyings available. More...
 
RE_VertexArraygetFeedbackBuffer (const char *attrib_name) const
 Fetch a vertex array written to by the shader. These are only valid after the shader has been linked for transform feedback (usually due to a draw call). Returns a vertex array for the named feedback buffer. More...
 
bool isFeedbackBufferUsed (RE_BufferType glattrib, int texlevel=0) const
 Check if a feedback buffer will be written by this shader Returns true if the attribute is available to be captured. Will return false if no buffer was setup to capture the attribute, or the shader does not output that attribute. This method must be called after the shader is linked. More...
 
bool isFeedbackBufferUsed (const char *attrib) const
 Check if a feedback buffer will be written by this shader Returns true if the attribute is available to be captured. Will return false if no buffer was setup to capture the attribute, or the shader does not output that attribute. This method must be called after the shader is linked. More...
 

Detailed Description

Member Enumeration Documentation

anonymous enum

Program name is readable, shader_version may be 0 or a valid GLSL version (110, 120, 130, 140, 150, 330, 400, 410, 420..)

Enumerator
USE_GLSL_BASE_VERSION 
USE_SHADER_GLSL_VERSION 

Definition at line 64 of file RE_Shader.h.

Constructor & Destructor Documentation

RE_Shader::RE_Shader ( const char *  program_name,
int  shader_version 
)
virtual RE_Shader::~RE_Shader ( )
virtual

Member Function Documentation

void RE_Shader::addCaptureGeometry ( RE_Geometry object,
bool  give_ownership = false 
)

Specify an RE_Geometry to collect data from Transform Feedback. Specify a geometry object to hold all the arrays for transform feedback. You retain ownership of the object unless 'give_ownership' is true. If no object is attached when the shader is linked, one will be created for you (with ownership maintained by this shader).

bool RE_Shader::addFeedbackBuffer ( const char *  attrib_name)

Specify a generic attribute to capture during transform feedback.

RE_ShaderStage* RE_Shader::addShader ( RE_Render r,
RE_ShaderType  stype,
const char *  shader_source,
const char *  shader_name,
int  codeversion,
UT_String messages = nullptr,
bool  print_source = true,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL,
bool  preprocess = false 
)

loadShader() loads a shader from an ASCII file. addShader() is used when the source is already available. 'messages' returns the warnings & errors (if any) from shader compilation. Multiple shaders can be attached to the same shader type; it is expected that one is the main shader, and others are functions.

virtual void RE_Shader::applyShader ( RE_Render r,
bool  update_re = true 
)
pure virtual

Implemented in RV_VKShader.

virtual bool RE_Shader::attachShader ( RE_Render r,
RE_ShaderStage obj,
UT_String messages = nullptr 
)
virtual

Individual Shader objects can be created separately and attached. returns true if the shader was attached, and false if it was already attached.

Reimplemented in RV_VKShader.

virtual bool RE_Shader::attachStorageBlock ( const RE_UniformBlockHandle block)
inlinevirtual

Attach a shader storage block to the binding point corresponding to its name. Shader storage blocks should be created with createStorageBlock().

Definition at line 755 of file RE_Shader.h.

virtual bool RE_Shader::attachStorageBuffer ( RE_VertexArray raw_buffer)
inlinevirtual

Attach a GL buffer to the shader storage block binding point that shares its name (getAttributeName()). This method is for simple storage blocks, such as "buffer blockname { vec4 color[]; }".

Definition at line 766 of file RE_Shader.h.

virtual bool RE_Shader::attachUniformBlock ( RE_UniformBlock )
inlinevirtual

Attach an RE_UniformBlock to this shader Attach a single uniform block to the shader. The shader owns the block while attached, and will delete it if the shader is deleted, or may delete it if linkShaders() is called and it is no longer in use. If you want to cache a block, detach it when you're done with the shader. If a block with the same name is already attached to this shader, it will be deleted.

Definition at line 676 of file RE_Shader.h.

virtual bool RE_Shader::bindAllUniformBlocks ( RE_Render )
inlinevirtual

Uploads attached uniform blocks that are dirty (uniform modifications) and ensures they are bound to the shader.

Definition at line 695 of file RE_Shader.h.

void RE_Shader::bindBuiltIns ( RE_Render r,
bool  force_update = false 
)

Bind all builtin uniforms. Bind all builtin uniforms this shader uses to their current values in RE_Render.

bool RE_Shader::bindColor ( RE_Render r,
const UT_StringHolder name,
const UT_Color c 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1329 of file RE_Shader.h.

bool RE_Shader::bindColor ( RE_Render r,
const UT_StringHolder name,
const UT_Color c,
fpreal  alpha 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1338 of file RE_Shader.h.

bool RE_Shader::bindDouble ( RE_Render r,
const UT_StringHolder name,
double  v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1317 of file RE_Shader.h.

bool RE_Shader::bindFloat ( RE_Render r,
const UT_StringHolder name,
float  v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1311 of file RE_Shader.h.

virtual bool RE_Shader::bindImage ( RE_Render r,
const UT_StringHolder name,
RE_Texture image,
RE_BufferAccess  image_access 
)
pure virtual

Bind a texture to an image slot for reading, writing, or both. Requires RE_EXT_IMAGE_LOAD_STORE (or GL4.2).

Implemented in RV_VKShader.

virtual bool RE_Shader::bindImageLayer ( RE_Render r,
const UT_StringHolder name,
RE_Texture image,
RE_BufferAccess  image_access,
int  layer 
)
pure virtual

Bind a texture array layer, cubemap layer, or a 3D texture slice to an image slot for reading, writing, or both. Requires RE_EXT_IMAGE_LOAD_STORE (or GL4.2).

Implemented in RV_VKShader.

bool RE_Shader::bindInt ( RE_Render r,
const UT_StringHolder name,
int  v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1305 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix2F m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1429 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix3F m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1435 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix4F m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1441 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix2D m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1447 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix3D m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1453 of file RE_Shader.h.

bool RE_Shader::bindMatrix ( RE_Render r,
const UT_StringHolder name,
const UT_Matrix4D m 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1459 of file RE_Shader.h.

virtual bool RE_Shader::bindMatrix2 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindMatrix2 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindMatrix3 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindMatrix3 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindMatrix4 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindMatrix4 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindTexture ( RE_Render r,
const UT_StringHolder name,
RE_Texture tex,
int saved_idx = 0 
)
pure virtual

Sampler buffer bound to a texture. The shader manages the texture unit assignment, the binding of the texture to the texture unit, and the assingment of the sampler buffer uniform.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindTextureMap ( RE_Render r,
const UT_StringHolder name,
const char *  mapname,
const char *  relative_to 
)
pure virtual

Bind a texture map using named textures in TIL_TextureMap. You can also bind a texture with its raw OpenGL ID using bindVariableInt().

Bind a new texture object using the mapname (filename, op:/coppath)

Implemented in RV_VKShader.

virtual bool RE_Shader::bindUint64 ( RE_Render r,
const UT_StringHolder name,
uint64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

64b Integer handle for bindless texturing

Implemented in RV_VKShader.

virtual bool RE_Shader::bindUniform ( RE_Render r,
const RE_Uniform uniform,
int  index = -1 
)
virtual

Bind an RE_Uniform's values to the corresponding GL uniform Bind an RE_Uniform to this shader. If 'uniform' is an array uniform then 'index' specifies which array element to bind. 'index' must be less than uniform->getSize(). Pass -1 for 'index' (the default) to bind all elements of an array; passing -1 for non-arrays is safe and is equivalent to passing 0.

virtual bool RE_Shader::bindVariable1 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable1 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable2 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable2 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable3 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable3 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable4 ( RE_Render r,
const UT_StringHolder name,
const fpreal32 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariable4 ( RE_Render r,
const UT_StringHolder name,
const fpreal64 val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariableInt ( RE_Render r,
const UT_StringHolder name,
const int val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer scalar.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariableInt2 ( RE_Render r,
const UT_StringHolder name,
const int val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer vector-2.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariableInt3 ( RE_Render r,
const UT_StringHolder name,
const int val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer vector-3.

Implemented in RV_VKShader.

virtual bool RE_Shader::bindVariableInt4 ( RE_Render r,
const UT_StringHolder name,
const int val,
int  array_size = 1,
int saved_idx = 0 
)
pure virtual

Generic Integer vector-4.

Implemented in RV_VKShader.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector2F v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1323 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector3F v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1350 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector4F v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1356 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector2D v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1362 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector3D v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1368 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector4D v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1374 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector2i v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1381 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector3i v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1387 of file RE_Shader.h.

bool RE_Shader::bindVector ( RE_Render r,
const UT_StringHolder name,
const UT_Vector4i v 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1393 of file RE_Shader.h.

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector2FArray vals 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1399 of file RE_Shader.h.

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector3FArray vals 
)

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector4FArray vals 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1408 of file RE_Shader.h.

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector2DArray vals 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1415 of file RE_Shader.h.

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector3DArray vals 
)

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

bool RE_Shader::bindVectors ( RE_Render r,
const UT_StringHolder name,
const UT_Vector4DArray vals 
)
inline

Set the value of a uniform. Set uniform value(s) for a specific type. False will be returned if the shader is not linked (errors?), the given name does not exist, or the type does not match the GLSL uniform type.

— Inlines

Definition at line 1422 of file RE_Shader.h.

bool RE_Shader::bindZeroConstant ( RE_Render r,
RE_VertexArray array 
)

Zero out the constant attribute location given by 'array' Bind a constant zero for this array. If data is non-nullptr, this data is used, otherwise the current constant data for this array is used (default 0's).

virtual void RE_Shader::cleanup ( RE_Render r)
pure virtual

Implemented in RV_VKShader.

bool RE_Shader::cleanupAfterDrawing ( RE_Render r,
RE_Geometry obj = nullptr,
RE_VertexState vstate = nullptr,
RE_OverrideList atrbover = 0 
)
void RE_Shader::clearAllFeedbackBuffers ( )

Remove all attributes from the capture gemetry.

virtual void RE_Shader::clearShaders ( RE_Render r,
RE_ShaderType  types = RE_SHADER_ALL 
)
virtual

Clears and deletes all the shader objects of a certain type (or all)

Reimplemented in RV_VKShader.

bool RE_Shader::clearTextureHandle ( RE_Render r,
const UT_StringHolder uniform_name,
int saved_idx = 0 
)

Remove a bindless handle from the uniform, clearing it to 0 (no tex).

virtual RE_UniformBlockHandle RE_Shader::copyUniformBlock ( const char *  name,
bool  data_too 
) const
inlinevirtual

Copies the structure of the named uniform block, and possibly the data.

Definition at line 707 of file RE_Shader.h.

static RE_Shader* RE_Shader::create ( const char *  name,
int  shader_version = 0,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL,
RE_Shader::Factory factory = nullptr 
)
static
static RE_Shader* RE_Shader::createShader ( RE_Render r,
const char *  name,
const char **  shader_files,
int  shader_version = USE_SHADER_GLSL_VERSION,
UT_String compile_msg = nullptr,
bool  use_houdini_libs = true,
RE_ShaderLanguage  s = RE_SHADER_LANGUAGE_GLSL,
bool  register_program = true,
const char *  extra_defines = nullptr,
RE_Shader::Factory factory = nullptr,
bool  dump_src_on_error = true 
)
static

Create a shader and load all shader files listed in shader_files, up to a nullptr filename. If the shader compiles and links, a non-nullptr shader will be returned. 'compile_msg' will contain any error messages otherwise. Shader stages must have extensions .vert, .geom and .frag.

static RE_Shader* RE_Shader::createShader ( RE_Render r,
const char *  name,
const char *  shader_files,
int  shader_version = USE_SHADER_GLSL_VERSION,
UT_String compile_msg = nullptr,
bool  use_houdini_libs = true,
RE_ShaderLanguage  s = RE_SHADER_LANGUAGE_GLSL,
bool  register_program = true,
const char *  extra_defines = nullptr,
RE_Shader::Factory factory = nullptr,
bool  dump_src_on_error = true 
)
static

A version with a single string containing whitespace-separated filenames.

virtual RE_UniformBlockHandle RE_Shader::createStorageBlock ( const char *  name,
int  array_size 
)
inlinevirtual

Create a buffer for buffer block 'name'. If it has an open-ended array, array_size specifies the size of that array, othwer it is ignored.

Definition at line 737 of file RE_Shader.h.

virtual bool RE_Shader::detachAllUniformBlocks ( )
inlinevirtual

Detaches all blocks referenced by this shader.

Definition at line 691 of file RE_Shader.h.

virtual bool RE_Shader::detachShader ( RE_Render r,
RE_ShaderStage obj 
)
virtual

Reimplemented in RV_VKShader.

virtual bool RE_Shader::detachStorageBinding ( const char *  bind_name)
inlinevirtual

Unbind the block or buffer attached to binding point 'bind_name'.

Definition at line 774 of file RE_Shader.h.

virtual bool RE_Shader::detachStorageBlock ( const RE_UniformBlockHandle block)
inlinevirtual

Detach a shader storage block from the binding point corresponding to its name.

Definition at line 760 of file RE_Shader.h.

virtual bool RE_Shader::detachStorageBuffer ( RE_VertexArray raw_buffer)
inlinevirtual

Detach a GL buffer from the shader storage block binding point that shares its name (raw_buffer->getAttributeName()).

Definition at line 770 of file RE_Shader.h.

virtual RE_UniformBlockHandle RE_Shader::detachUniformBlock ( const char *  )
inlinevirtual

Detach a named RE_UniformBlock from this shader Detach a single uniform block by name or pointer. The shader will no longer keep a reference to it, and will not delete it when relinking or when the shader is deleted. Note that a shader must have all blocks attached when executed. Detaching a uniform block does not remove the GL binding to the block, it merely removes this shader's ownership of the block (for performance reasons)

Definition at line 685 of file RE_Shader.h.

virtual bool RE_Shader::detachUniformBlock ( RE_UniformBlock )
inlinevirtual

Detach a specific RE_UniformBlock from this shader.

Definition at line 688 of file RE_Shader.h.

static int RE_Shader::determineCodeVersion ( const char *  shader_string)
static

determine the version of the shader from the source (#version <num>) return 100 if no version is specified.

void RE_Shader::disableShadingRate ( )
inline

Disables the shading rate for this shader. The rate set by RE_Render::setShaderSampleRate() is used instead.

Definition at line 367 of file RE_Shader.h.

UT_StringHolder RE_Shader::findSamplerAtUnit ( int  tex_unit) const
int RE_Shader::getAnisotropySamples ( ) const
inline

Set anisotropic filtering for textures bound via bindTextureMap()

Definition at line 938 of file RE_Shader.h.

const char* RE_Shader::getAttribNameForLocation ( int  loc) const

Returns the name of a vertex shader input at GL location 'loc'.

bool RE_Shader::getAttribute ( const char *  attrib_name,
int location,
RE_GPUType type,
int size 
) const

Return information about vertex shader input 'attrib_name' Returns the location and size of the named vertex attribute, or false if it does not exist in this shader. This also includes the GL built-ins, though these will not set location type, or size; only return true/false for their presence in the shader.

bool RE_Shader::getAttributeIndex ( int  index,
UT_String name,
int location,
RE_GPUType type,
int size 
) const

Return information about vertex shader input at 'index' Similar to getAttribute(), but the name of the input does not need to be known. GL builtins are not supported by this method. index must be within [0, getNumAttribs()-1].

virtual int RE_Shader::getAttributeIndex ( const char *  name) const
protectedvirtual
int RE_Shader::getAttributeModeLoc ( RE_GenericAttribID  t) const
inline

Return the default GL location of generic vertex attribute 't'.

Definition at line 826 of file RE_Shader.h.

int RE_Shader::getAttributeSamplerLoc ( RE_GenericAttribID  t) const
inline

Return the texture sampler unit of a texture buffer object for 't'.

Definition at line 830 of file RE_Shader.h.

static int RE_Shader::getBaseGLSLVersion ( )
static

Returns the minimum GLSL version supported (base requirement)

static int RE_Shader::getBaseGLSLVersion ( RE_ShaderLanguage  lang)
static

Returns the minimum GLSL version supported for specific language type.

int RE_Shader::getBlockIndexForUniform ( int  idx) const

Return the index of the uniform block a uniform is in, -1 for none.

const char* RE_Shader::getBufferAttrib ( int  i) const
inline

Return the name of texture-buffer object attribute at index 'i'.

Definition at line 844 of file RE_Shader.h.

RE_GenericAttribID RE_Shader::getBufferAttribID ( int  i) const
inline

Definition at line 846 of file RE_Shader.h.

const char* RE_Shader::getBufferTextureName ( int  i) const

Name of the texture buffer object sampler at index 'i'.

RE_GPUType RE_Shader::getBufferTextureType ( int  i) const

Type of the texture buffer object sampler at index 'i' (float, int, uint)

const char* RE_Shader::getBuiltinAttrib ( int  i) const
inline

Return the name of GL-builtin vertex shader input at index 'i'.

Definition at line 837 of file RE_Shader.h.

const UT_IntArray& RE_Shader::getBuiltInUniformList ( ) const
inline

Returns a list of RE_UniformBuiltIn IDs this shader uses.

Definition at line 622 of file RE_Shader.h.

RE_Geometry* RE_Shader::getCaptureGeometry ( bool  take_ownership = false)

Return the capture geometry for transform feedback.

static bool RE_Shader::getCodeBlock ( const char *  block_name,
UT_StringHolder block_source,
RE_ShaderLanguage  lang 
)
static
int RE_Shader::getCodeVersion ( ) const
inline

Returns the version of the shader (110,120,130,140,150,330,400,410).

Definition at line 144 of file RE_Shader.h.

static RE_Texture* RE_Shader::getDefaultTBO ( RE_Render r)
staticprotected
const char* RE_Shader::getDefines ( ) const
inline

Any define commands used to alter this shader.

Definition at line 132 of file RE_Shader.h.

RE_VertexArray* RE_Shader::getFeedbackBuffer ( const char *  attrib_name) const

Fetch a vertex array written to by the shader. These are only valid after the shader has been linked for transform feedback (usually due to a draw call). Returns a vertex array for the named feedback buffer.

void RE_Shader::getGeometryParms ( int maxverts,
RE_PrimType input_type,
RE_PrimType output_type 
) const
inline

Fetch current geometry shader values. Return the geometry shader parameters specified by setGeometryParms() or the shader itself (via layout(in=triangles), etc).

Definition at line 275 of file RE_Shader.h.

int RE_Shader::getLightMask ( ) const
inline

Cached RE_LightList information (uniform blocks)

Definition at line 967 of file RE_Shader.h.

int RE_Shader::getLinkSerial ( ) const
inline

Bumped every time a link is performed (uniforms invalidated, etc).

Definition at line 235 of file RE_Shader.h.

int RE_Shader::getMaxTextureHeight ( ) const
inline

Limit the resolution of the textures to a max width and height.

Definition at line 919 of file RE_Shader.h.

int RE_Shader::getMaxTextureWidth ( ) const
inline

Limit the resolution of the textures to a max width and height.

Definition at line 918 of file RE_Shader.h.

virtual int RE_Shader::getMaxUniformBlocks ( RE_Render )
inlinevirtual

Returns the OpenGL maximum number of supported blocks.

Definition at line 649 of file RE_Shader.h.

virtual int RE_Shader::getMaxUniformBlockSizeB ( RE_Render )
inlinevirtual

Returns the OpenGL maximum size of a uniform block, in bytes.

Definition at line 652 of file RE_Shader.h.

virtual int64 RE_Shader::getMemoryUsage ( bool  inclusive) const
virtual

Returns the amount of main memory (NOT graphics memory!) owned by this RE_Shader.

Reimplemented in RV_VKShader.

const char* RE_Shader::getName ( ) const
inline

Readable name of the shader.

Definition at line 129 of file RE_Shader.h.

int RE_Shader::getNumBufferAttribs ( ) const
inline

Return the number of texture-buffer object attributes.

Definition at line 841 of file RE_Shader.h.

int RE_Shader::getNumBufferTextures ( ) const

Return the number of texture buffer object samplers in this shader.

int RE_Shader::getNumBuiltinAttribs ( ) const
inline

Return the number of GL-builtin vertex shader inputs (gl_Vertex, gl_*)

Definition at line 834 of file RE_Shader.h.

int RE_Shader::getNumImages ( ) const
inline

Return the number of image samplers this shader references (GL4.2 shader load/store images, not regular texture samplers)

Definition at line 438 of file RE_Shader.h.

int RE_Shader::getNumShaderAttribs ( ) const
inline

Return the number of vertex shader input attributes.

Definition at line 784 of file RE_Shader.h.

int RE_Shader::getNumTextures ( ) const
inline

Return the number of samplers this shader references.

Definition at line 434 of file RE_Shader.h.

int RE_Shader::getNumTextures ( RE_ShaderType  stage) const

Returns the number of texture samplers used by shader 'stage'. As RE_ShaderType is a bitfield, multiple stages can be queried at once and the sum will be returned. Requires RE_EXT_PROGRAM_INTERFACE_QUERY.

virtual int RE_Shader::getNumUniformBlocks ( ) const
inlinevirtual

Returns the number of blocks and specific uniform blocks.

Definition at line 656 of file RE_Shader.h.

int RE_Shader::getNumUniforms ( ) const
inline

Returns the number of active uniforms in this shader.

Definition at line 475 of file RE_Shader.h.

virtual RE_UniformBlockHandle RE_Shader::getOverrideBlock ( int  ) const
inlinevirtual

Return the currently bound override block for an index, if any is bound.

Definition at line 731 of file RE_Shader.h.

int RE_Shader::getProgram ( ) const
inline

Raw GL id of the shader.

Definition at line 135 of file RE_Shader.h.

RE_ShaderStage* RE_Shader::getShader ( const char *  shader_name,
RE_ShaderType  hint = RE_SHADER_ALL 
)

Returns an attached shader by the given name.

static RE_Shader* RE_Shader::getShader ( int  program_object)
static

Fetch a shader based on GL program id Returns the RE_Shader object with the specified program object if it exists; otherwise, returns nullptr.

RE_GenericAttribID RE_Shader::getShaderAttribGenID ( int  i) const
inline

Return the ID of the attribute if it is a known type, or RE_GENATTRIB_UNDEF if it is not.

Definition at line 1465 of file RE_Shader.h.

int RE_Shader::getShaderAttribLocation ( int  i) const
inline

Return the GL attribute location of vertex shader input at index 'i'.

Definition at line 799 of file RE_Shader.h.

const UT_IntArray& RE_Shader::getShaderAttribLocations ( ) const
inline

Return an int array of all vertex shader input locations.

Definition at line 815 of file RE_Shader.h.

const char* RE_Shader::getShaderAttribName ( int  i) const
inline

Return the name of vertex shader input at index 'i'.

Definition at line 791 of file RE_Shader.h.

const UT_StringList& RE_Shader::getShaderAttribNames ( ) const
inline

Return a string array of all vertex shader input names.

Definition at line 811 of file RE_Shader.h.

int RE_Shader::getShaderAttribSize ( int  i) const
inline

Return the vector size of vertex shader input at index 'i'.

Definition at line 807 of file RE_Shader.h.

const UT_IntArray& RE_Shader::getShaderAttribSizes ( ) const
inline

Return an int array of all vertex shader input sizes.

Definition at line 819 of file RE_Shader.h.

RE_GPUType RE_Shader::getShaderAttribType ( int  i) const
inline

Return the type of vertex shader input at index 'i'.

Definition at line 803 of file RE_Shader.h.

virtual re_LibFunc* RE_Shader::getShaderLibrary ( ) const
protectedvirtual

Reimplemented in RV_VKShader.

void RE_Shader::getShaderSource ( RE_Render r,
UT_String source,
RE_ShaderType  sh = RE_SHADER_ALL 
)

Returns the shader source of some or all attached shaders.

fpreal RE_Shader::getShadingRate ( ) const
inline

For multisampled framebuffers, this sets the fraction of samples that should be shaded by a fragment shader, from 0.0 to 1.0. For example, setting this to 0.5 would guarentee at least 4 color samples for a 8x multisample buffer. The default is 0.0 (1 color sample, N coverage) This only has an effect on GL4 hardware. It is ignored unless RE_EXT_SAMPLE_SHADING is supported.

Definition at line 360 of file RE_Shader.h.

virtual RE_UniformBlockHandle RE_Shader::getStorageBlock ( const char *  name)
inlinevirtual

Return the block definition for storage block 'name'.

Definition at line 742 of file RE_Shader.h.

virtual RE_UniformBlockHandle RE_Shader::getStorageBlockBinding ( const char *  name)
inlinevirtual

Return the storage block bound to 'name' (bound by attachStorageBlock)

Definition at line 746 of file RE_Shader.h.

virtual RE_VertexArray* RE_Shader::getStorageBufferBinding ( const char *  name)
inlinevirtual

Return the raw buffer bound to 'name' (bound by attachStorageBlock)

Definition at line 750 of file RE_Shader.h.

RE_TextureCompress RE_Shader::getTextureFormat ( ) const
inline

Override texture compression for texture bound via bindTextureMap()

Definition at line 908 of file RE_Shader.h.

virtual RE_TextureDimension RE_Shader::getTextureMapType ( RE_Render r,
const UT_StringHolder name 
)
pure virtual

Return the texture type for the sampler named 'name'.

Implemented in RV_VKShader.

const char* RE_Shader::getTextureSamplerName ( int  tex_index) const

Return the name of a sampler uniform Return the texture sampler name of the enumerated samplers at 'tex_index' Must be within [0, getNumTextures()-1].

RE_TextureDimension RE_Shader::getTextureSamplerType ( int  tex_index) const

Return the texture sampler type at 'tex_index' [0, getNumTextures()-1].

float RE_Shader::getTextureScale ( ) const
inline

Scale by a constant scale factor for textures bound via bindTextureMap()

Definition at line 925 of file RE_Shader.h.

const char** RE_Shader::getTransformFeedbackAttribs ( int num_attribs)
protected
virtual RE_UniformBlockHandle RE_Shader::getUniformBlock ( int  ) const
inlinevirtual

Return an attached uniform block by index.

Definition at line 659 of file RE_Shader.h.

virtual RE_UniformBlockHandle RE_Shader::getUniformBlock ( const char *  name) const
inlinevirtual

Return an attached uniform block by name.

Definition at line 662 of file RE_Shader.h.

virtual int RE_Shader::getUniformBlockIndex ( const char *  name) const
inlinevirtual

Returns the block binding point of the named block.

Definition at line 666 of file RE_Shader.h.

int RE_Shader::getUniformImageUnit ( const UT_StringHolder uniform_name) const

return the image unit of sampler 'uniform_name' Return the image unit this image uniform has been assigned to, or -1 if 'uniform_name' does not exist, or is not a image uniform. Images are different than textures, used by RE_EXT_IMAGE_LOAD_STORE (GL4.2).

int RE_Shader::getUniformIndex ( const UT_StringHolder name) const
protected
int RE_Shader::getUniformLocation ( int  idx) const

Return the GL uniform location of uniform 'idx' [0, getNumUniforms()-1].

const char* RE_Shader::getUniformName ( int  idx) const

Returns the name of active uniform 'idx' [0, getNumUniforms()-1].

int RE_Shader::getUniformTextureUnit ( const UT_StringHolder uniform_name,
int  array_index = 0 
) const

return the texture unit of sampler 'uniform_name' Return the texture unit this sampler has been assigned to, or -1 if 'uniform_name' does not exist, or is not a sampler. array_index is used to identify indices of sampler arrays.

RE_UniformType RE_Shader::getUniformType ( const UT_StringHolder uniform_name) const

Return the uniform type of the uniform named 'uniform_name', or RE_UNIFORM_INVALID if it does not exist.

RE_UniformType RE_Shader::getUniformType ( int  idx) const

Return the GL uniform type 'idx' [ 0, getNumUniforms()-1].

exint RE_Shader::getUniqueID ( ) const
inline

Definition at line 70 of file RE_Shader.h.

bool RE_Shader::hasAttribute ( const char *  attrib_name) const
inline

Simpler version of getAttribute() - just returns if the attribute exists.

Definition at line 869 of file RE_Shader.h.

bool RE_Shader::hasBufferTexture ( const char *  name) const

True if the shader has a texture buffer object sampler named 'name'.

bool RE_Shader::hasBuiltInUniform ( RE_UniformBuiltIn  uniform) const

Queries the use of a builtin uniform Returns true if this shader has the specified built-in uniform. 'uniform' must be an RE_UniformBuiltIn. Note that certain built-in uniforms may only be supported for certain languages.

bool RE_Shader::hasShader ( RE_ShaderType  type) const

Returns true if this shader program has a shader of 'type' attached. type may be a bitmask of shader types, in which case it returns true if any of the shader types exist.

bool RE_Shader::hasShaderAttribs ( ) const
inline

Return if the vertex shader has input attributes.

Definition at line 780 of file RE_Shader.h.

bool RE_Shader::hasTessellation ( ) const
inline

Definition at line 787 of file RE_Shader.h.

bool RE_Shader::hasTransformFeedback ( ) const

True if this shader has transform feedback varyings available.

bool RE_Shader::hasUniform ( const UT_StringHolder uniform_name) const

returns true if the named uniform exists in the shader.

virtual bool RE_Shader::initUniformBlock ( RE_Render r,
RE_UniformBlock block,
int  index = -1 
) const
inlinevirtual

Initialize a uniform block based on this shader's block layout Initializes a uniform block with the proper offsets and size for block index 'index'. If index is -1, block must have the name of one of the uniform blocks in the shader.

Definition at line 701 of file RE_Shader.h.

void RE_Shader::invalidateUniform ( RE_UniformBuiltIn  uniform)

Called to invalidate the cached uniform, usually by RE_Uniform::unregisterBuiltIn().

bool RE_Shader::isFeedbackBufferUsed ( RE_BufferType  glattrib,
int  texlevel = 0 
) const

Check if a feedback buffer will be written by this shader Returns true if the attribute is available to be captured. Will return false if no buffer was setup to capture the attribute, or the shader does not output that attribute. This method must be called after the shader is linked.

bool RE_Shader::isFeedbackBufferUsed ( const char *  attrib) const

Check if a feedback buffer will be written by this shader Returns true if the attribute is available to be captured. Will return false if no buffer was setup to capture the attribute, or the shader does not output that attribute. This method must be called after the shader is linked.

bool RE_Shader::isLinked ( ) const
inline

True if the shader has been successfully linked.

Definition at line 141 of file RE_Shader.h.

bool RE_Shader::isSampleShading ( ) const
inline

For multisampled framebuffers, this sets the fraction of samples that should be shaded by a fragment shader, from 0.0 to 1.0. For example, setting this to 0.5 would guarentee at least 4 color samples for a 8x multisample buffer. The default is 0.0 (1 color sample, N coverage) This only has an effect on GL4 hardware. It is ignored unless RE_EXT_SAMPLE_SHADING is supported.

Definition at line 362 of file RE_Shader.h.

void RE_Shader::limitTextureSize ( bool  limit,
int  w,
int  h 
)

Limit the resolution of the textures to a max width and height.

bool RE_Shader::limitTextureSize ( ) const
inline

Limit the resolution of the textures to a max width and height.

Definition at line 916 of file RE_Shader.h.

virtual bool RE_Shader::linkShaders ( RE_Render r,
UT_String messages = nullptr 
)
virtual

Links all the shaders together; called implicitly if needed by RE_Render::setShader(). Note that linking the shader will clear out any uniforms that have been set.

Reimplemented in RV_VKShader.

virtual void RE_Shader::loadBoundTextures ( RE_Render r)
pure virtual

Implemented in RV_VKShader.

static bool RE_Shader::loadFile ( const char *  filename,
const char *  defines,
UT_WorkBuffer src,
int codeversion,
UT_String messages,
int  default_code_version = 0,
int  max_verts = -1,
bool  adjust_line_num = false,
bool  loadingInclude = false,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL 
)
static
bool RE_Shader::loadHoudiniLibraryFuncs ( RE_Render r,
UT_String msg,
RE_ShaderLanguage  lang 
)
protected
static int RE_Shader::loadProgramFile ( RE_Render r,
const char *  file,
const char *  basepath,
UT_String prog_name,
UT_StringArray files,
UT_StringArray files_names,
UT_StringArray inputs,
UT_StringArray outputs,
UT_StringArray defines,
int codeversion,
fpreal shading_rate,
int max_verts,
bool &  use_attrib_map,
bool &  explicit_attrib_map,
int  max_version,
RE_ShaderLanguage shader_lang,
UT_String msg 
)
static
RE_ShaderStage* RE_Shader::loadShader ( RE_Render r,
RE_ShaderType  stype,
const char *  filename,
UT_String messages = nullptr,
const char *  shader_name = nullptr,
const char *  defines = "",
int  default_code_version = USE_GLSL_BASE_VERSION,
int  geom_max_verts = -1,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL,
bool  print_source = true 
)

loadShader() loads a shader from an ASCII file. addShader() is used when the source is already available. 'messages' returns the warnings & errors (if any) from shader compilation. Multiple shaders can be attached to the same shader type; it is expected that one is the main shader, and others are functions.

virtual void RE_Shader::loadShaderTexMaps ( RE_Render )
pure virtual

Loads texture maps specified by the RE_TextureMap bindTextureMap()

Implemented in RV_VKShader.

static RE_Shader* RE_Shader::lookupProgram ( int  id)
static
bool RE_Shader::matchesLights ( int  light_serial,
int  light_id 
) const

Cached RE_LightList information (uniform blocks)

bool RE_Shader::mipMapTextures ( ) const
inline

Enable or disable mipmapping for textures bound via bindTextureMap()

Definition at line 930 of file RE_Shader.h.

void RE_Shader::mipMapTextures ( bool  yes)
inline

Enable or disable mipmapping for textures bound via bindTextureMap()

Definition at line 931 of file RE_Shader.h.

virtual RE_ShaderStage* RE_Shader::newShader ( RE_ShaderType  type,
const char *  name = 0 
)
pure virtual

Allocate a new shader stage of the specified type, with an optional readable name.

Implemented in RV_VKShader.

virtual int RE_Shader::overrideUniformBlock ( RE_UniformBlock block,
int  block_index = -1 
)
inlinevirtual

Override the currently bound uniform block without deleting the block currently residing at that index. If 'block_index' is -1, the name of the block is used to find the block index. Only one override can be active at once. Passing nullptr for the block clears the override.

Definition at line 720 of file RE_Shader.h.

bool RE_Shader::prepForDrawing ( RE_Render r,
RE_Geometry obj = nullptr,
RE_ElementArray element = nullptr,
RE_VertexState state = nullptr,
unsigned int  vertex_stride = 0,
RE_OverrideList atrbover = 0,
int  instance_group = 0 
)

Prepare this shader for rendering Binds uniform buffer objects and all builtin uniforms. Optionally re-binds vertex attribute locations in 'obj'.

void RE_Shader::printAttributes ( std::ostream *  os = nullptr) const
virtual void RE_Shader::printUniforms ( RE_Render r,
std::ostream *  os = nullptr 
) const
inlinevirtual

Prints all the active uniforms plus their values to stream os (or cerr)

Reimplemented in RV_VKShader.

Definition at line 636 of file RE_Shader.h.

static void RE_Shader::processCodeLine ( const char *  line,
int  line_num,
const char *  defines,
UT_WorkBuffer src,
int codeversion,
UT_String messages,
int  default_code_version,
bool &  found_codeversion,
int  max_verts,
bool  adjust_line_num,
RE_ShaderLanguage  lang 
)
staticprotected
static void RE_Shader::registerProgram ( RE_Shader shader,
int  program_object 
)
staticprotected
static void RE_Shader::removeAllTextureRefs ( RE_OGLTexture )
static
bool RE_Shader::removeFeedbackBuffer ( const char *  attrib_name)

Remove a generic attribute from the capture geometry.

virtual void RE_Shader::removeOverrideBlock ( int  )
inlinevirtual

Remove an override block from the shader, by index.

Definition at line 724 of file RE_Shader.h.

virtual void RE_Shader::removeOverrideBlock ( RE_UniformBlock b)
inlinevirtual

Remove a specific override block from the shader.

Definition at line 726 of file RE_Shader.h.

virtual void RE_Shader::removeOverrideBlocks ( )
inlinevirtual

Remove all override blocks from the shader.

Examples:
tetprim/GR_PrimTetra.C.

Definition at line 728 of file RE_Shader.h.

virtual void RE_Shader::removeShader ( RE_Render r,
bool  update_re = true 
)
pure virtual

Implemented in RV_VKShader.

virtual void RE_Shader::removeTextureRefs ( RE_OGLTexture )
inlineprotectedvirtual

Definition at line 1021 of file RE_Shader.h.

virtual bool RE_Shader::runCompute ( RE_Render r,
int  num_wg_x,
int  num_wg_y = 1,
int  num_wg_z = 1 
)
virtual

COMPUTE.

virtual bool RE_Shader::runCompute ( RE_Render r,
RE_VertexArray wg_buffer,
int  offset 
)
virtual
static void RE_Shader::scanSourceForFuncs ( const char *  line,
RE_ShaderType  shtype,
UT_Array< re_NeededLibFuncs > &  needed,
re_LibFunc library,
int  glmajor,
int  glminor 
)
staticprotected
void RE_Shader::setAnisotropySamples ( int  samples)
inline

Set anisotropic filtering for textures bound via bindTextureMap()

Definition at line 936 of file RE_Shader.h.

void RE_Shader::setFeedbackBufferSize ( int  num_vertices)

Will generate a new owned capture geometry if one isn't present.

virtual bool RE_Shader::setFragmentOutput ( RE_Render r,
const char *  name,
int  buffer_index 
)
virtual

bind fragment shader output 'name' to color attachment 'buffer_index'. Must be called before linking. Only needed for custom fragment output (ie, not gl_FragData[] or gl_FragColor).

Reimplemented in RV_VKShader.

virtual bool RE_Shader::setGeometryParms ( RE_Render r,
int  max_vertices,
RE_PrimType  input,
RE_PrimType  output 
)
virtual

Specify geometry shader parameters.

Reimplemented in RV_VKShader.

void RE_Shader::setGeomMaxVerts ( int  max_verts)
inlineprotected

Definition at line 1073 of file RE_Shader.h.

void RE_Shader::setLightID ( int  light_serial,
int  light_id,
int  mask 
)

Cached RE_LightList information (uniform blocks)

void RE_Shader::setRegisterProgram ( bool  register_program)

If true, register this shader so that RE_Shader::getShader() can find this shader (default is true).

void RE_Shader::setShadingRate ( fpreal  rate)
inline

For multisampled framebuffers, this sets the fraction of samples that should be shaded by a fragment shader, from 0.0 to 1.0. For example, setting this to 0.5 would guarentee at least 4 color samples for a 8x multisample buffer. The default is 0.0 (1 color sample, N coverage) This only has an effect on GL4 hardware. It is ignored unless RE_EXT_SAMPLE_SHADING is supported.

Definition at line 358 of file RE_Shader.h.

void RE_Shader::setTextureFormat ( RE_TextureCompress  format)
inline

Override texture compression for texture bound via bindTextureMap()

Definition at line 909 of file RE_Shader.h.

bool RE_Shader::setTextureHandle ( RE_Render r,
const UT_StringHolder uniform_name,
RE_Texture texture,
int saved_idx = 0 
)

assign a bindless texture to its handle uniform. 'texture' must have a texture handle, and uniform_name must refer to a texture handle.

void RE_Shader::setTextureScale ( float  sc)
inline

Scale by a constant scale factor for textures bound via bindTextureMap()

Definition at line 924 of file RE_Shader.h.

bool RE_Shader::setUniformTextureUnit ( RE_Render r,
const UT_StringHolder uniform_name,
int  unit_index 
)

Set a binding point for the given sampler.

virtual bool RE_Shader::setVertexInput ( RE_Render r,
const char *  name,
int  vertex_index 
)
virtual

bind vertex shader input 'name' to vertex array index 'vertex_index'. Must be called before linking, or a re-link must be done.

Reimplemented in RV_VKShader.

virtual void RE_Shader::unloadBoundTextures ( RE_Render r)
pure virtual

Implemented in RV_VKShader.

static void RE_Shader::unregisterProgram ( int  program_object)
static
virtual bool RE_Shader::updateUniformBlock ( const RE_UniformBlockHandle b) const
inlinevirtual

Update an offset/name/size information in 'b' with the uniforms for the correspondingly-named uniform block in this shader.

Definition at line 713 of file RE_Shader.h.

void RE_Shader::useDefaultAttribMap ( bool  enable = true)

If true, this shader follows the default Houdini attribute map.

void RE_Shader::useExplicitAttribMap ( bool  enable = true)

If true, this shader defines its own attribute locations in shader code Do not move any attributes.

void RE_Shader::useHoudiniLibraryFuncs ( )

If true, this shader may use Houdini's builtin functions.

virtual bool RE_Shader::validateShader ( RE_Render r,
UT_String messages = nullptr 
)
virtual

Ensures that the shader can run given the current GL state. This mostly deals with texture bindings matching what is expected by the shader. If this returns false, the shader will not run, and 'messages' can be used to fetch the reason.

Reimplemented in RV_VKShader.

Member Data Documentation

UT_Array<RE_GenericAttribID> RE_Shader::myAttribGenIDs
protected

Definition at line 1109 of file RE_Shader.h.

UT_IntArray RE_Shader::myAttribLocations
protected

Definition at line 1108 of file RE_Shader.h.

UT_StringList RE_Shader::myAttribNames
protected

Definition at line 1105 of file RE_Shader.h.

UT_IntArray RE_Shader::myAttribSizes
protected

Definition at line 1111 of file RE_Shader.h.

UT_Array<RE_GPUType> RE_Shader::myAttribTypes
protected

Definition at line 1110 of file RE_Shader.h.

UT_IntArray RE_Shader::myAttrModeLocs
protected

Definition at line 1120 of file RE_Shader.h.

UT_IntArray RE_Shader::myAttrSamplerLocs
protected

Definition at line 1121 of file RE_Shader.h.

UT_Array<RE_GenericAttribID> RE_Shader::myBufferAttribGenIDs
protected

Definition at line 1107 of file RE_Shader.h.

UT_StringList RE_Shader::myBufferAttribNames
protected

Definition at line 1106 of file RE_Shader.h.

UT_IntArray RE_Shader::myBufferTextures
protected

Definition at line 1128 of file RE_Shader.h.

UT_StringList RE_Shader::myBuiltInAttribNames
protected

Definition at line 1104 of file RE_Shader.h.

UT_ValArray<const RE_Uniform *> RE_Shader::myBuiltInLastUniform
protected

Definition at line 1117 of file RE_Shader.h.

int RE_Shader::myBuiltInMap[RE_UNIFORM_BUILT_IN__count]
protected

Definition at line 1123 of file RE_Shader.h.

UT_IntArray RE_Shader::myBuiltInUniforms
protected

Definition at line 1115 of file RE_Shader.h.

int64 RE_Shader::myBuiltInUniformSerial
protected

Definition at line 1124 of file RE_Shader.h.

UT_IntArray RE_Shader::myBuiltInVersion
protected

Definition at line 1116 of file RE_Shader.h.

int RE_Shader::myCodeVersion
protected

Definition at line 1131 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myComputeShaders
protected

Definition at line 1096 of file RE_Shader.h.

UT_IntArray RE_Shader::myDrawBoundTextures
protected

Definition at line 1147 of file RE_Shader.h.

UT_String RE_Shader::myExtraDefines
protected

Definition at line 1078 of file RE_Shader.h.

UT_StringList RE_Shader::myFeedbackNames
protected

Definition at line 1112 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myFragmentShaders
protected

Definition at line 1095 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myGeometryShaders
protected

Definition at line 1094 of file RE_Shader.h.

RE_PrimType RE_Shader::myGeoShaderInputPrims
protected

Definition at line 1101 of file RE_Shader.h.

int RE_Shader::myGeoShaderMaxVertices
protected

Definition at line 1100 of file RE_Shader.h.

RE_PrimType RE_Shader::myGeoShaderOutputPrims
protected

Definition at line 1102 of file RE_Shader.h.

UT_IntArray RE_Shader::myImageUniforms
protected

Definition at line 1139 of file RE_Shader.h.

int RE_Shader::myLightMask
protected

Definition at line 1144 of file RE_Shader.h.

int RE_Shader::myLightsId
protected

Definition at line 1143 of file RE_Shader.h.

int RE_Shader::myLightsSerial
protected

Definition at line 1142 of file RE_Shader.h.

bool RE_Shader::myLimitTextureSize
protected

Definition at line 1085 of file RE_Shader.h.

bool RE_Shader::myLinkedFlag
protected

Definition at line 1080 of file RE_Shader.h.

int RE_Shader::myMaxTexH
protected

Definition at line 1086 of file RE_Shader.h.

int RE_Shader::myMaxTexW
protected

Definition at line 1086 of file RE_Shader.h.

bool RE_Shader::myMipMapTexture
protected

Definition at line 1088 of file RE_Shader.h.

UT_Array<re_NeededLibFuncs>* RE_Shader::myNeededLibraryFuncs
protected

Definition at line 1130 of file RE_Shader.h.

UT_IntArray RE_Shader::myNumTexturesPerStage
protected

Definition at line 1098 of file RE_Shader.h.

UT_String RE_Shader::myProgramName
protected

Definition at line 1077 of file RE_Shader.h.

int RE_Shader::myProgramObject
protected

Definition at line 1079 of file RE_Shader.h.

bool RE_Shader::myRegisterProgram
protected

Definition at line 1083 of file RE_Shader.h.

int64 RE_Shader::myRenderSerial
protected

Definition at line 1125 of file RE_Shader.h.

int RE_Shader::myShaderSerial
protected

Definition at line 1141 of file RE_Shader.h.

fpreal RE_Shader::myShadingRate
protected

Definition at line 1137 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myTessControlShaders
protected

Definition at line 1092 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myTessEvalShaders
protected

Definition at line 1093 of file RE_Shader.h.

RE_TextureCompress RE_Shader::myTexFormat
protected

Definition at line 1084 of file RE_Shader.h.

int RE_Shader::myTextureAnisotropy
protected

Definition at line 1089 of file RE_Shader.h.

float RE_Shader::myTextureScale
protected

Definition at line 1087 of file RE_Shader.h.

UT_IntArray RE_Shader::myTextureUniforms
protected

Definition at line 1138 of file RE_Shader.h.

RE_Geometry* RE_Shader::myTransformFeedbackGeometry
protected

Definition at line 1133 of file RE_Shader.h.

bool RE_Shader::myTransformFeedbackGeometryOwned
protected

Definition at line 1134 of file RE_Shader.h.

UT_ValArray<re_VertexName *> RE_Shader::myTransformFeedbackVertices
protected

Definition at line 1135 of file RE_Shader.h.

UT_SymbolMap<int> RE_Shader::myUniformBlockTable
protected

Definition at line 1119 of file RE_Shader.h.

UT_ValArray<RE_UniformData *> RE_Shader::myUniforms
protected

Definition at line 1114 of file RE_Shader.h.

UT_SymbolMap<int> RE_Shader::myUniformTable
protected

Definition at line 1118 of file RE_Shader.h.

exint RE_Shader::myUniqueID
protected

Definition at line 1145 of file RE_Shader.h.

bool RE_Shader::myUseDefaultAttribMap
protected

Definition at line 1081 of file RE_Shader.h.

bool RE_Shader::myUseExplicitAttribMap
protected

Definition at line 1082 of file RE_Shader.h.

RE_VertexMap* RE_Shader::myVertexMap
protected

Definition at line 1127 of file RE_Shader.h.

UT_ValArray<RE_ShaderStage *> RE_Shader::myVertexShaders
protected

Definition at line 1091 of file RE_Shader.h.

UT_WorkBuffer RE_Shader::myWorkBuffer
protected

Definition at line 1148 of file RE_Shader.h.


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