MaterialX 1.38.7
No Matches
Shader Class Reference

Class containing all data needed during shader generation. More...

#include <Shader.h>

Public Member Functions

 Shader (const string &name, ShaderGraphPtr graph)
virtual ~Shader ()
const string & getName () const
 Return the shader name.
size_t numStages () const
 Return the number of shader stages for this shader.
ShaderStagegetStage (size_t index)
 Return a stage by index.
const ShaderStagegetStage (size_t index) const
 Return a stage by index.
bool hasStage (const string &name)
 Return if stage exists.
ShaderStagegetStage (const string &name)
 Return a stage by name.
const ShaderStagegetStage (const string &name) const
 Return a stage by name.
bool hasAttribute (const string &attrib) const
 Return true if the shader has a given named attribute.
ValuePtr getAttribute (const string &attrib) const
 Return the value for a named attribute, or nullptr if no such attribute is found.
void setAttribute (const string &attrib, ValuePtr value)
 Set a value attribute on the shader.
void setAttribute (const string &attrib)
 Set a flag attribute on the shader.
const ShaderGraphgetGraph () const
 Return the shader graph.
ShaderGraphgetGraph ()
 Return the shader graph.
bool hasClassification (unsigned int c) const
 Return true if this shader matches the given classification.
void setSourceCode (const string &code, const string &stage=Stage::PIXEL)
 Set the shader source code for a given shader stage.
const string & getSourceCode (const string &stage=Stage::PIXEL) const
 Return the shader source code for a given shader stage.

Protected Member Functions

ShaderStagePtr createStage (const string &name, ConstSyntaxPtr syntax)
 Create a new stage in the shader.

Protected Attributes

string _name
ShaderGraphPtr _graph
std::unordered_map< string, ShaderStagePtr_stagesMap
vector< ShaderStage * > _stages
std::unordered_map< string, ValuePtr_attributeMap


class ShaderGenerator

Detailed Description

Class containing all data needed during shader generation.

After generation is completed it will contain the resulting source code emitted by shader generators.

The class contains a default implementation using a single shader stage. Derived shaders can override this, as well as overriding all methods that add code to the shader.

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