MaterialX 1.38.2
OslShaderGenerator.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_OSLSHADERGENERATOR_H
7#define MATERIALX_OSLSHADERGENERATOR_H
8
11
13
15
16namespace MaterialX
17{
18
19using OslShaderGeneratorPtr = shared_ptr<class OslShaderGenerator>;
20
24class MX_GENOSL_API OslShaderGenerator : public ShaderGenerator
25{
26 public:
28
29 static ShaderGeneratorPtr create() { return std::make_shared<OslShaderGenerator>(); }
30
32 const string& getTarget() const override { return TARGET; }
33
36 ShaderPtr generate(const string& name, ElementPtr element, GenContext& context) const override;
37
39 void emitFunctionCalls(const ShaderGraph& graph, GenContext& context, ShaderStage& stage) const override;
40
42 static const string TARGET;
43
45 void registerShaderMetadata(const DocumentPtr& doc, GenContext& context) const override;
46
47protected:
48
50 virtual ShaderPtr createShader(const string& name, ElementPtr element, GenContext& context) const;
51
53 virtual void emitIncludes(ShaderStage& stage, GenContext& context) const;
54
56 virtual void emitShaderInputs(const VariableBlock& inputs, ShaderStage& stage) const;
57
59 virtual void emitShaderOutputs(const VariableBlock& inputs, ShaderStage& stage) const;
60};
61
62namespace OSL
63{
65 extern MX_GENOSL_API const string UNIFORMS;
66 extern MX_GENOSL_API const string INPUTS;
67 extern MX_GENOSL_API const string OUTPUTS;
68}
69
70} // namespace MaterialX
71
72#endif
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
Macros for declaring imported and exported symbols.
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
shared_ptr< ShaderGenerator > ShaderGeneratorPtr
Shared pointer to a ShaderGenerator.
Definition: Library.h:38
Base shader generator class.
A context class for shader generation.
Definition: GenContext.h:27
Base class for OSL (Open Shading Language) shader generators.
Definition: OslShaderGenerator.h:25
const string & getTarget() const override
Return a unique identifier for the target this generator is for.
Definition: OslShaderGenerator.h:32
static const string TARGET
Unique identifier for this generator target.
Definition: OslShaderGenerator.h:42
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
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