6#ifndef MATERIALX_SHADERGENERATOR_H
7#define MATERIALX_SHADERGENERATOR_H
46 virtual void emitScopeEnd(
ShaderStage& stage,
bool semicolon =
false,
bool newline =
true)
const;
49 virtual void emitLineBegin(
ShaderStage& stage)
const;
52 virtual void emitLineEnd(
ShaderStage& stage,
bool semicolon =
true)
const;
55 virtual void emitLineBreak(
ShaderStage& stage)
const;
58 virtual void emitString(
const string& str,
ShaderStage& stage)
const;
61 virtual void emitLine(
const string& str,
ShaderStage& stage,
bool semicolon =
true)
const;
64 virtual void emitComment(
const string& str,
ShaderStage& stage)
const;
85 bool checkScope =
true)
const;
112 bool assignValue =
true)
const;
121 bool assignValue =
true)
const;
130 void registerImplementation(
const string& name, CreatorFunction<ShaderNodeImpl> creator);
133 bool implementationRegistered(
const string& name)
const;
138 _colorManagementSystem = colorManagementSystem;
144 return _colorManagementSystem;
150 _unitSystem = unitSystem;
168 return _tokenSubstitutions;
202 virtual void finalizeShaderGraph(
ShaderGraph& graph);
214 static const string T_FILE_TRANSFORM_UV;
230 using Exception::Exception;
Color management system classes.
shared_ptr< class ColorManagementSystem > ColorManagementSystemPtr
A shared pointer to a ColorManagementSystem.
Definition: ColorManagementSystem.h:26
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:23
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
Class instantiator factory helper class.
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
Definition: Library.h:58
Macros for declaring imported and exported symbols.
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
shared_ptr< ShaderStage > ShaderStagePtr
Shared pointer to a ShaderStage.
Definition: Library.h:36
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
Class related to holding information for shader stages.
Base class for syntax handling for shader generators.
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
Definition: Syntax.h:26
shared_ptr< class UnitSystem > UnitSystemPtr
A shared pointer to a UnitSystem.
Definition: UnitSystem.h:27
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Exception.h:23
An exception that is thrown when shader generation fails.
Definition: ShaderGenerator.h:228
Factory class for creating instances of classes given their type name.
Definition: Factory.h:20
A context class for shader generation.
Definition: GenContext.h:27
An implementation element within a Document.
Definition: Definition.h:194
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:317
A node graph element within a Document.
Definition: Node.h:316
Base class for shader generators All third-party shader generators should derive from this class.
Definition: ShaderGenerator.h:30
ColorManagementSystemPtr getColorManagementSystem() const
Returns the color management system.
Definition: ShaderGenerator.h:142
virtual const string & getTarget() const =0
Return the name of the target this generator is for.
const StringMap & getTokenSubstitutions() const
Return the map of token substitutions used by the generator.
Definition: ShaderGenerator.h:166
void setUnitSystem(UnitSystemPtr unitSystem)
Sets the unit system.
Definition: ShaderGenerator.h:148
void emitValue(const T &value, ShaderStage &stage) const
Add a value.
Definition: ShaderGenerator.h:75
void setColorManagementSystem(ColorManagementSystemPtr colorManagementSystem)
Sets the color management system.
Definition: ShaderGenerator.h:136
const Syntax & getSyntax() const
Return the syntax object for the language used by the code generator.
Definition: ShaderGenerator.h:127
virtual ~ShaderGenerator()
Destructor.
Definition: ShaderGenerator.h:33
void setFunctionName(const string &functionName, ShaderStage &stage) const
Set function name for a stage.
Definition: ShaderGenerator.h:205
virtual ShaderPtr generate(const string &name, ElementPtr element, GenContext &context) const =0
Generate a shader starting from the given element, translating the element and all dependencies upstr...
UnitSystemPtr getUnitSystem() const
Returns the unit system.
Definition: ShaderGenerator.h:154
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:45
Class containing all data needed during shader generation.
Definition: Shader.h:34
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:326
An output on a ShaderNode.
Definition: ShaderNode.h:289
An input or output port on a ShaderNode.
Definition: ShaderNode.h:125
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:124
void setFunctionName(const string &functionName)
Set stage function name.
Definition: ShaderStage.h:234
void addValue(const T &value)
Add a value.
Definition: ShaderStage.h:223
Base class for syntax objects used by shader generators to emit code with correct syntax for each lan...
Definition: Syntax.h:40
Punctuation
Punctuation types.
Definition: Syntax.h:44
A block of variables in a shader stage.
Definition: ShaderStage.h:53