![]() |
MaterialX 1.39.5
|
Shader generator for MDL (Material Definition Language). More...
#include <MdlShaderGenerator.h>
Public Member Functions | |
| MdlShaderGenerator (TypeSystemPtr typeSystem) | |
| Constructor. | |
| const string & | getTarget () const override |
| Return a unique identifier for the target this generator is for. | |
| void | applyDefaultOptions (GenOptions &options) const override |
| Apply the default GenOptions for MDL shader generation. | |
| ShaderPtr | generate (const string &name, ElementPtr element, GenContext &context) const override |
| Generate a shader starting from the given element, translating the element and all dependencies upstream into shader code. | |
| ShaderNodeImplPtr | createShaderNodeImplForNodeGraph (const NodeGraph &nodegraph) const override |
| Create the shader node implementation for a NodeGraph implementation. | |
| ShaderNodeImplPtr | createShaderNodeImplForImplementation (const Implementation &implementation) const override |
| Create the shader node implementation for an mplementation implementation. | |
| string | getUpstreamResult (const ShaderInput *input, GenContext &context) const override |
| Return the result of an upstream connection or value for an input. | |
| GenMdlOptions::MdlVersion | getMdlVersion (GenContext &context) const |
| Get the selected MDL target language version number from the context option. | |
| void | emitMdlVersionNumber (GenContext &context, ShaderStage &stage) const |
| Add the MDL file header containing the version number of the generated module. | |
| void | emitMdlVersionFilenameSuffix (GenContext &context, ShaderStage &stage) const |
| Add the version number suffix appended to MDL modules that use versions. | |
| const string & | getMdlVersionFilenameSuffix (GenContext &context) const |
| Get the version number suffix appended to MDL modules that use versions. | |
| void | emitTypeDefinitions (GenContext &context, ShaderStage &stage) const override |
| Emit type definitions for all data types that need them. | |
Public Member Functions inherited from ShaderGenerator | |
| virtual | ~ShaderGenerator () |
| Destructor. | |
| virtual void | emitScopeBegin (ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const |
| Start a new scope using the given bracket type. | |
| virtual void | emitScopeEnd (ShaderStage &stage, bool semicolon=false, bool newline=true) const |
| End the current scope. | |
| virtual void | emitLineBegin (ShaderStage &stage) const |
| Start a new line. | |
| virtual void | emitLineEnd (ShaderStage &stage, bool semicolon=true) const |
| End the current line. | |
| virtual void | emitLineBreak (ShaderStage &stage) const |
| Add a line break. | |
| virtual void | emitString (const string &str, ShaderStage &stage) const |
| Add a string. | |
| virtual void | emitLine (const string &str, ShaderStage &stage, bool semicolon=true) const |
| Add a single line of code, optionally appending a semicolon. | |
| virtual void | emitComment (const string &str, ShaderStage &stage) const |
| Add a single line code comment. | |
| virtual void | emitBlock (const string &str, const FilePath &sourceFilename, GenContext &context, ShaderStage &stage) const |
| Add a block of code. | |
| virtual void | emitLibraryInclude (const FilePath &filename, GenContext &context, ShaderStage &stage) const |
| Add the contents of a standard library include file if not already present. | |
| template<typename T> | |
| void | emitValue (const T &value, ShaderStage &stage) const |
| Add a value. | |
| virtual void | emitFunctionDefinition (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Add the function definition for a single node. | |
| virtual void | emitFunctionDefinitionParameter (const ShaderPort *shaderPort, bool isOutput, GenContext &context, ShaderStage &stage) const |
| virtual void | emitFunctionDefinitions (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const |
| Add all function definitions for a graph. | |
| virtual void | emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Add the function call for a single node. | |
| virtual void | emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage, bool checkScope) const |
| virtual void | emitFunctionCalls (const ShaderGraph &graph, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const |
| Add all function calls for a graph. | |
| virtual void | emitDependentFunctionCalls (const ShaderNode &node, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const |
| Add function calls for nodes connected directly upstream from the given node. | |
| virtual void | emitFunctionBodyBegin (const ShaderNode &node, GenContext &context, ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const |
| Emit code for starting a new function body. | |
| virtual void | emitFunctionBodyEnd (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Emit code for ending a function body. | |
| virtual void | emitInput (const ShaderInput *input, GenContext &context, ShaderStage &stage) const |
| Emit the connected variable name for an input, or constant value if the port is not connected. | |
| virtual void | emitOutput (const ShaderOutput *output, bool includeType, bool assignValue, GenContext &context, ShaderStage &stage) const |
| Emit the output variable name for an output, optionally including it's type and default value assignment. | |
| virtual void | emitVariableDeclarations (const VariableBlock &block, const string &qualifier, const string &separator, GenContext &context, ShaderStage &stage, bool assignValue=true) const |
| Emit definitions for all shader variables in a block. | |
| virtual void | emitVariableDeclaration (const ShaderPort *variable, const string &qualifier, GenContext &context, ShaderStage &stage, bool assignValue=true) const |
| Emit definition of a single shader variable. | |
| virtual bool | nodeNeedsClosureData (const ShaderNode &) const |
| Return true if the node needs the additional ClosureData added. | |
| virtual void | emitClosureDataArg (const ShaderNode &, GenContext &, ShaderStage &) const |
| Emit the closure data argument if required Note this is an affordance for HwShaderGenerator. | |
| virtual void | emitClosureDataParameter (const ShaderNode &, GenContext &, ShaderStage &) const |
| Emit the closure data parameter if required. | |
| const Syntax & | getSyntax () const |
| Return the syntax object for the language used by the code generator. | |
| void | registerImplementation (const string &name, CreatorFunction< ShaderNodeImpl > creator) |
| Register a shader node implementation for a given implementation element name. | |
| void | registerImplementation (const StringVec &nameVec, CreatorFunction< ShaderNodeImpl > creator) |
| Register a shader node implementation for a given set of implementation element names. | |
| bool | implementationRegistered (const string &name) const |
| Determine if a shader node implementation has been registered for a given implementation element name. | |
| virtual ShaderNodeImplPtr | getImplementation (const NodeDef &nodedef, GenContext &context) const |
| Return a registered shader node implementation for the given nodedef. | |
| void | setColorManagementSystem (ColorManagementSystemPtr colorManagementSystem) |
| Sets the color management system. | |
| ColorManagementSystemPtr | getColorManagementSystem () const |
| Returns the color management system. | |
| void | setUnitSystem (UnitSystemPtr unitSystem) |
| Sets the unit system. | |
| UnitSystemPtr | getUnitSystem () const |
| Returns the unit system. | |
| TypeSystemPtr | getTypeSystem () const |
| Returns the type system. | |
| const StringMap & | getTokenSubstitutions () const |
| Return the map of token substitutions used by the generator. | |
| void | registerRefactor (ShaderGraphRefactorPtr refactor) |
| Register a shader graph refactoring pass. | |
| const vector< ShaderGraphRefactorPtr > & | getRefactors () const |
| Return the registered graph refactoring passes. | |
| virtual void | registerTypeDefs (const DocumentPtr &doc) |
| Register type definitions from the document. | |
| virtual void | registerShaderMetadata (const DocumentPtr &doc, GenContext &context) const |
| Register metadata that should be exported to the generated shaders. | |
| virtual const string & | getLightDataTypevarString () const |
Static Public Member Functions | |
| static ShaderGeneratorPtr | create (TypeSystemPtr typeSystem=nullptr) |
| Creator function. | |
Protected Member Functions | |
| ShaderPtr | createShader (const string &name, ElementPtr element, GenContext &context) const |
| void | emitShaderInputs (const VariableBlock &inputs, ShaderStage &stage) const |
Protected Member Functions inherited from ShaderGenerator | |
| ShaderGenerator (TypeSystemPtr typeSystem, SyntaxPtr syntax) | |
| Protected constructor. | |
| virtual ShaderStagePtr | createStage (const string &name, Shader &shader) const |
| Create a new stage in a shader. | |
| void | setFunctionName (const string &functionName, ShaderStage &stage) const |
| Set function name for a stage. | |
| void | replaceTokens (const StringMap &substitutions, ShaderStage &stage) const |
| Replace tokens with identifiers according to the given substitutions map. | |
| void | createVariables (ShaderGraphPtr graph, GenContext &context, Shader &shader) const |
| Create shader variables (e.g. | |
Additional Inherited Members | |
Protected Attributes inherited from ShaderGenerator | |
| TypeSystemPtr | _typeSystem |
| SyntaxPtr | _syntax |
| Factory< ShaderNodeImpl > | _implFactory |
| ColorManagementSystemPtr | _colorManagementSystem |
| UnitSystemPtr | _unitSystem |
| StringMap | _tokenSubstitutions |
| vector< ShaderGraphRefactorPtr > | _refactors |
| friend | ShaderGraph |
Static Protected Attributes inherited from ShaderGenerator | |
| static const string | T_FILE_TRANSFORM_UV |
| static const string | LIGHTDATA_TYPEVAR_STRING |
Shader generator for MDL (Material Definition Language).
|
overridevirtual |
Apply the default GenOptions for MDL shader generation.
Reimplemented from ShaderGenerator.
|
inlinestatic |
Creator function.
If a TypeSystem is not provided it will be created internally. Optionally pass in an externally created TypeSystem here, if you want to keep type descriptions alive after the lifetime of the shader generator.
|
overridevirtual |
Create the shader node implementation for an mplementation implementation.
Reimplemented from ShaderGenerator.
|
overridevirtual |
Create the shader node implementation for a NodeGraph implementation.
Reimplemented from ShaderGenerator.
|
overridevirtual |
Emit type definitions for all data types that need them.
Reimplemented from ShaderGenerator.
|
overridevirtual |
Generate a shader starting from the given element, translating the element and all dependencies upstream into shader code.
Reimplemented from ShaderGenerator.
| GenMdlOptions::MdlVersion getMdlVersion | ( | GenContext & | context | ) | const |
Get the selected MDL target language version number from the context option.
If not set, the latest version supported by GenMdl is returned.
|
inlineoverridevirtual |
Return a unique identifier for the target this generator is for.
Reimplemented from ShaderGenerator.
|
overridevirtual |
Return the result of an upstream connection or value for an input.
Reimplemented from ShaderGenerator.