forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShaderNodeImpl.cpp
More file actions
85 lines (67 loc) · 2.05 KB
/
ShaderNodeImpl.cpp
File metadata and controls
85 lines (67 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <MaterialXGenShader/ShaderNodeImpl.h>
#include <MaterialXGenShader/Shader.h>
#include <MaterialXGenShader/ShaderGenerator.h>
#include <MaterialXGenShader/ShaderNode.h>
#include <MaterialXGenShader/GenContext.h>
MATERIALX_NAMESPACE_BEGIN
//
// ShaderNodeImpl methods
//
ShaderNodeImpl::ShaderNodeImpl() :
_name(EMPTY_STRING),
_hash(0)
{
}
void ShaderNodeImpl::initialize(const InterfaceElement& element, GenContext&)
{
// Store name
_name = element.getName();
// By default use the implementation name as hash to make it unique.
// Derived classes can override this to create other hashes,
// e.g. to share the same hash beteen nodes that can share
// the same function definition.
_hash = std::hash<string>{}(_name);
}
void ShaderNodeImpl::addInputs(ShaderNode&, GenContext&) const
{
}
void ShaderNodeImpl::setValues(const Node&, ShaderNode&, GenContext&) const
{
}
void ShaderNodeImpl::addClassification(ShaderNode&) const
{
}
void ShaderNodeImpl::createVariables(const ShaderNode&, GenContext&, Shader&) const
{
}
void ShaderNodeImpl::emitFunctionDefinition(const ShaderNode&, GenContext&, ShaderStage&) const
{
}
void ShaderNodeImpl::emitFunctionCall(const ShaderNode&, GenContext&, ShaderStage&) const
{
}
void ShaderNodeImpl::emitOutputVariables(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
{
// Default implementation of output variable declaration.
// Initialize variables to their type default value.
const ShaderGenerator& shadergen = context.getShaderGenerator();
for (size_t i = 0; i < node.numOutputs(); ++i)
{
shadergen.emitLineBegin(stage);
shadergen.emitOutput(node.getOutput(i), true, true, context, stage);
shadergen.emitLineEnd(stage);
}
}
ShaderGraph* ShaderNodeImpl::getGraph() const
{
return nullptr;
}
ShaderNodeImplPtr NopNode::create()
{
return std::make_shared<NopNode>();
}
MATERIALX_NAMESPACE_END