MaterialX 1.39.1
Loading...
Searching...
No Matches
Util.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_RENDER_UTIL_H
7#define MATERIALX_RENDER_UTIL_H
8
11
13
17
18#include <map>
19
20MATERIALX_NAMESPACE_BEGIN
21
22extern MX_RENDER_API const Color3 DEFAULT_SCREEN_COLOR_SRGB;
23extern MX_RENDER_API const Color3 DEFAULT_SCREEN_COLOR_LIN_REC709;
24
27
29MX_RENDER_API ShaderPtr createShader(const string& shaderName, GenContext& context, ElementPtr elem);
30
34 DocumentPtr stdLib,
35 const string& shaderName,
36 const Color3& color);
37
40MX_RENDER_API ShaderPtr createDepthShader(GenContext& context,
41 DocumentPtr stdLib,
42 const string& shaderName);
43
47 DocumentPtr stdLib,
48 const string& shaderName);
49
52 DocumentPtr stdLib,
53 const string& shaderName);
54
56MX_RENDER_API ShaderPtr createBlurShader(GenContext& context,
57 DocumentPtr stdLib,
58 const string& shaderName,
59 const string& filterType,
60 float filterSize);
61
65
67struct MX_RENDER_API UIProperties
68{
70 string uiName;
71
73 string uiFolder;
74
77
79 vector<ValuePtr> enumerationValues;
80
83
86
89
92
95
97 bool uiAdvanced = false;
98};
99
102MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string& target, UIProperties& uiProperties);
103
105struct MX_RENDER_API UIPropertyItem
106{
107 string label;
108 ShaderPort* variable = nullptr;
109 UIProperties ui;
110};
111
113using UIPropertyGroup = std::multimap<string, UIPropertyItem>;
114
117MX_RENDER_API void createUIPropertyGroups(DocumentPtr doc, const VariableBlock& block, UIPropertyGroup& groups,
118 UIPropertyGroup& unnamedGroups, const string& pathSeparator);
119
121
122MATERIALX_NAMESPACE_END
123
124#endif
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
Context classes for shader generation.
shared_ptr< Input > InputPtr
A shared pointer to an Input.
Definition: Interface.h:31
vector< string > StringVec
A vector of strings.
Definition: Library.h:55
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
Shader generation utility methods.
Macros for declaring imported and exported symbols.
MX_RENDER_API void createUIPropertyGroups(DocumentPtr doc, const VariableBlock &block, UIPropertyGroup &groups, UIPropertyGroup &unnamedGroups, const string &pathSeparator)
Utility to group UI properties items based on Element group name from a VariableBlock.
MX_RENDER_API ShaderPtr createConstantShader(GenContext &context, DocumentPtr stdLib, const string &shaderName, const Color3 &color)
Create a shader with a constant color output, using the given standard libraries for code generation.
MX_RENDER_API ShaderPtr createBlurShader(GenContext &context, DocumentPtr stdLib, const string &shaderName, const string &filterType, float filterSize)
Create a blur shader, using the given standard libraries for code generation.
MX_RENDER_API ShaderPtr createAlbedoTableShader(GenContext &context, DocumentPtr stdLib, const string &shaderName)
Create a shader that generates a look-up table for directional albedo, using the given standard libra...
MX_RENDER_API ShaderPtr createDepthShader(GenContext &context, DocumentPtr stdLib, const string &shaderName)
Create a shader with depth value output, using the given standard libraries for code generation.
std::multimap< string, UIPropertyItem > UIPropertyGroup
A grouping of property items by name.
Definition: Util.h:113
MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string &target, UIProperties &uiProperties)
Get the UI properties for a given input element and target.
MX_RENDER_API ShaderPtr createEnvPrefilterShader(GenContext &context, DocumentPtr stdLib, const string &shaderName)
Create a shader that generates a prefiltered environment map.
MX_RENDER_API ShaderPtr createShader(const string &shaderName, GenContext &context, ElementPtr elem)
Create a shader for a given element.
Base shader generator class.
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
A three-component color value.
Definition: Types.h:342
A context class for shader generation.
Definition: GenContext.h:31
An input or output port on a ShaderNode.
Definition: ShaderNode.h:123
A block of variables in a shader stage.
Definition: ShaderStage.h:61
Set of possible UI properties for an element.
Definition: Util.h:68
ValuePtr uiStep
UI step value.
Definition: Util.h:94
ValuePtr uiMin
UI minimum value.
Definition: Util.h:82
ValuePtr uiSoftMin
UI soft minimum value.
Definition: Util.h:88
string uiName
UI name.
Definition: Util.h:70
StringVec enumeration
Enumeration.
Definition: Util.h:76
vector< ValuePtr > enumerationValues
Enumeration Values.
Definition: Util.h:79
ValuePtr uiSoftMax
UI soft maximum value.
Definition: Util.h:91
string uiFolder
UI folder.
Definition: Util.h:73
ValuePtr uiMax
UI maximum value.
Definition: Util.h:85
Interface for holding the UI properties associated shader port.
Definition: Util.h:106