MaterialX 1.38.10
Loading...
Searching...
No Matches
GlslMaterial Class Reference

Helper class for GLSL generation and rendering of a material. More...

#include <GlslMaterial.h>

Inheritance diagram for GlslMaterial:
ShaderMaterial

Public Member Functions

bool loadSource (const FilePath &vertexShaderFile, const FilePath &pixelShaderFile, bool hasTransparency) override
 Load shader source from file. More...
 
bool generateShader (GenContext &context) override
 Generate a shader from our currently stored element and the given generator context. More...
 
bool generateShader (ShaderPtr hwShader) override
 Generate a shader from the given hardware shader. More...
 
void copyShader (MaterialPtr material) override
 Copy shader from one material to this one. More...
 
GlslProgramPtr getProgram () const
 Return the underlying GLSL program.
 
bool bindShader () const override
 Bind shader. More...
 
void bindViewInformation (CameraPtr camera) override
 Bind viewing information for this material. More...
 
void bindImages (ImageHandlerPtr imageHandler, const FileSearchPath &searchPath, bool enableMipmaps=true) override
 Bind all images for this material. More...
 
void unbindImages (ImageHandlerPtr imageHandler) override
 Unbbind all images for this material. More...
 
ImagePtr bindImage (const FilePath &filePath, const std::string &uniformName, ImageHandlerPtr imageHandler, const ImageSamplingProperties &samplingProperties) override
 Bind a single image. More...
 
void bindLighting (LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler, const ShadowState &shadowState) override
 Bind lights to shader. More...
 
void bindMesh (MeshPtr mesh) override
 Bind the given mesh to this material. More...
 
bool bindPartition (MeshPartitionPtr part) const override
 Bind a mesh partition to this material. More...
 
void drawPartition (MeshPartitionPtr part) const override
 Draw the given mesh partition. More...
 
void unbindGeometry () override
 Unbind all geometry from this material. More...
 
VariableBlockgetPublicUniforms () const override
 Return the block of public uniforms for this material. More...
 
ShaderPortfindUniform (const std::string &path) const override
 Find a public uniform from its MaterialX path. More...
 
void modifyUniform (const std::string &path, ConstValuePtr value, std::string valueString=EMPTY_STRING) override
 Modify the value of the uniform with the given path. More...
 
- Public Member Functions inherited from ShaderMaterial
void setDocument (DocumentPtr doc)
 Set the renderable element associated with this ShaderMaterial.
 
DocumentPtr getDocument () const
 Return the document associated with this ShaderMaterial.
 
void setElement (TypedElementPtr val)
 Set the renderable element associated with this ShaderMaterial.
 
TypedElementPtr getElement () const
 Return the renderable element associated with this ShaderMaterial.
 
void setMaterialNode (NodePtr node)
 Set the ShaderMaterial node associated with this ShaderMaterial.
 
NodePtr getMaterialNode () const
 Return the ShaderMaterial node associated with this ShaderMaterial.
 
void setUdim (const std::string &val)
 Set udim identifier.
 
const std::string & getUdim ()
 Get any associated udim identifier.
 
virtual bool loadSource (const FilePath &vertexShaderFile, const FilePath &pixelShaderFile, bool hasTransparency)=0
 Load shader source from file. More...
 
virtual bool generateShader (GenContext &context)=0
 Generate a shader from our currently stored element and the given generator context. More...
 
virtual void copyShader (MaterialPtr ShaderMaterial)=0
 Copies shader and API specific generated program from ShaderMaterial to this one. More...
 
virtual bool generateShader (ShaderPtr hwShader)=0
 Generate a shader from the given hardware shader. More...
 
virtual bool generateEnvironmentShader (GenContext &context, const FilePath &filename, DocumentPtr stdLib, const FilePath &imagePath)
 Generate an environment background shader.
 
ShaderPtr getShader () const
 Return the underlying hardware shader.
 
bool hasTransparency () const
 Return true if this ShaderMaterial has transparency.
 
virtual bool bindShader () const =0
 Bind shader. More...
 
virtual void bindViewInformation (CameraPtr camera)=0
 Bind viewing information for this ShaderMaterial. More...
 
virtual void bindImages (ImageHandlerPtr imageHandler, const FileSearchPath &searchPath, bool enableMipmaps=true)=0
 Bind all images for this ShaderMaterial. More...
 
virtual void unbindImages (ImageHandlerPtr imageHandler)=0
 Unbbind all images for this ShaderMaterial. More...
 
virtual ImagePtr bindImage (const FilePath &filePath, const std::string &uniformName, ImageHandlerPtr imageHandler, const ImageSamplingProperties &samplingProperties)=0
 Bind a single image. More...
 
virtual void bindLighting (LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler, const ShadowState &shadowState)=0
 Bind lights to shader. More...
 
virtual void bindMesh (MeshPtr mesh)=0
 Bind the given mesh to this ShaderMaterial. More...
 
virtual bool bindPartition (MeshPartitionPtr part) const =0
 Bind a mesh partition to this ShaderMaterial. More...
 
virtual void drawPartition (MeshPartitionPtr part) const =0
 Draw the given mesh partition. More...
 
virtual void unbindGeometry ()=0
 Unbind all geometry from this ShaderMaterial. More...
 
virtual VariableBlockgetPublicUniforms () const =0
 Return the block of public uniforms for this ShaderMaterial. More...
 
virtual ShaderPortfindUniform (const std::string &path) const =0
 Find a public uniform from its MaterialX path. More...
 
virtual void modifyUniform (const std::string &path, ConstValuePtr value, std::string valueString=EMPTY_STRING)=0
 Modify the value of the uniform with the given path. More...
 

Static Public Member Functions

static GlslMaterialPtr create ()
 

Protected Member Functions

void clearShader () override
 
virtual void clearShader ()=0
 

Protected Attributes

GlslProgramPtr _glProgram
 
- Protected Attributes inherited from ShaderMaterial
ShaderPtr _hwShader
 
MeshPtr _boundMesh
 
DocumentPtr _doc
 
TypedElementPtr _elem
 
NodePtr _materialNode
 
std::string _udim
 
bool _hasTransparency
 
ImageVec _boundImages
 

Detailed Description

Helper class for GLSL generation and rendering of a material.

Member Function Documentation

◆ bindImage()

ImagePtr bindImage ( const FilePath filePath,
const std::string &  uniformName,
ImageHandlerPtr  imageHandler,
const ImageSamplingProperties samplingProperties 
)
overridevirtual

Bind a single image.

Implements ShaderMaterial.

◆ bindImages()

void bindImages ( ImageHandlerPtr  imageHandler,
const FileSearchPath searchPath,
bool  enableMipmaps = true 
)
overridevirtual

Bind all images for this material.

Implements ShaderMaterial.

◆ bindLighting()

void bindLighting ( LightHandlerPtr  lightHandler,
ImageHandlerPtr  imageHandler,
const ShadowState shadowState 
)
overridevirtual

Bind lights to shader.

Implements ShaderMaterial.

◆ bindMesh()

void bindMesh ( MeshPtr  mesh)
overridevirtual

Bind the given mesh to this material.

Implements ShaderMaterial.

◆ bindPartition()

bool bindPartition ( MeshPartitionPtr  part) const
overridevirtual

Bind a mesh partition to this material.

Implements ShaderMaterial.

◆ bindShader()

bool bindShader ( ) const
overridevirtual

Bind shader.

Implements ShaderMaterial.

◆ bindViewInformation()

void bindViewInformation ( CameraPtr  camera)
overridevirtual

Bind viewing information for this material.

Implements ShaderMaterial.

◆ clearShader()

void clearShader ( )
overrideprotectedvirtual

Implements ShaderMaterial.

◆ copyShader()

void copyShader ( MaterialPtr  material)
inlineoverridevirtual

Copy shader from one material to this one.

Implements ShaderMaterial.

◆ drawPartition()

void drawPartition ( MeshPartitionPtr  part) const
overridevirtual

Draw the given mesh partition.

Implements ShaderMaterial.

◆ findUniform()

ShaderPort * findUniform ( const std::string &  path) const
overridevirtual

Find a public uniform from its MaterialX path.

Implements ShaderMaterial.

◆ generateShader() [1/2]

bool generateShader ( GenContext context)
overridevirtual

Generate a shader from our currently stored element and the given generator context.

Implements ShaderMaterial.

◆ generateShader() [2/2]

bool generateShader ( ShaderPtr  hwShader)
overridevirtual

Generate a shader from the given hardware shader.

Implements ShaderMaterial.

◆ getPublicUniforms()

VariableBlock * getPublicUniforms ( ) const
overridevirtual

Return the block of public uniforms for this material.

Implements ShaderMaterial.

◆ loadSource()

bool loadSource ( const FilePath vertexShaderFile,
const FilePath pixelShaderFile,
bool  hasTransparency 
)
overridevirtual

Load shader source from file.

Implements ShaderMaterial.

◆ modifyUniform()

void modifyUniform ( const std::string &  path,
ConstValuePtr  value,
std::string  valueString = EMPTY_STRING 
)
overridevirtual

Modify the value of the uniform with the given path.

Implements ShaderMaterial.

◆ unbindGeometry()

void unbindGeometry ( )
overridevirtual

Unbind all geometry from this material.

Implements ShaderMaterial.

◆ unbindImages()

void unbindImages ( ImageHandlerPtr  imageHandler)
overridevirtual

Unbbind all images for this material.

Implements ShaderMaterial.


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