MaterialX 1.38.2
MdlShaderGenerator.h
Go to the documentation of this file.
1//
2// TM & (c) 2020 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_MDLSHADERGENERATOR_H
7#define MATERIALX_MDLSHADERGENERATOR_H
8
11
13
15
16namespace MaterialX
17{
18
20using MdlShaderGeneratorPtr = shared_ptr<class MdlShaderGenerator>;
21
24class MX_GENMDL_API MdlShaderGenerator : public ShaderGenerator
25{
26 public:
28
29 static ShaderGeneratorPtr create() { return std::make_shared<MdlShaderGenerator>(); }
30
32 const string& getTarget() const override { return TARGET; }
33
36 ShaderPtr generate(const string& name, ElementPtr element, GenContext& context) const override;
37
39 string getUpstreamResult(const ShaderInput* input, GenContext& context) const override;
40
42 static const string TARGET;
43
44 protected:
45 // Create and initialize a new MDL shader for shader generation.
46 ShaderPtr createShader(const string& name, ElementPtr element, GenContext& context) const;
47
48 // Override the sourcecode implementation creator
49 ShaderNodeImplPtr createSourceCodeImplementation(const Implementation& impl) const override;
50
51 // Override the compound implementation creator.
52 ShaderNodeImplPtr createCompoundImplementation(const NodeGraph& impl) const override;
53
54 // Override the shader graph finalization.
55 void finalizeShaderGraph(ShaderGraph& graph) override;
56
57 // Emit a block of shader inputs.
58 void emitShaderInputs(const VariableBlock& inputs, ShaderStage& stage) const;
59};
60
61namespace MDL
62{
63 // Identifiers for MDL variable blocks
64 extern MX_GENMDL_API const string INPUTS;
65 extern MX_GENMDL_API const string OUTPUTS;
66}
67
68} // namespace MaterialX
69
70#endif
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
Macros for declaring imported and exported symbols.
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
shared_ptr< ShaderGenerator > ShaderGeneratorPtr
Shared pointer to a ShaderGenerator.
Definition: Library.h:38
shared_ptr< class MdlShaderGenerator > MdlShaderGeneratorPtr
Shared pointer to an MdlShaderGenerator.
Definition: MdlShaderGenerator.h:20
Base shader generator class.
A context class for shader generation.
Definition: GenContext.h:27
An implementation element within a Document.
Definition: Definition.h:194
Shader generator for MDL (Material Definition Language).
Definition: MdlShaderGenerator.h:25
const string & getTarget() const override
Return a unique identifier for the target this generator is for.
Definition: MdlShaderGenerator.h:32
static const string TARGET
Unique identifier for this generator target.
Definition: MdlShaderGenerator.h:42
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
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:45
An input on a ShaderNode.
Definition: ShaderNode.h:256
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:124
A block of variables in a shader stage.
Definition: ShaderStage.h:53