HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
9 /// @file
10 /// Rendering utility methods
11 
12 #include <MaterialXRender/Export.h>
13 
17 
18 #include <map>
19 
21 
24 
25 /// @name Shader Utilities
26 /// @{
27 
28 /// Create a shader for a given element.
29 MX_RENDER_API ShaderPtr createShader(const string& shaderName, GenContext& context, ElementPtr elem);
30 
31 /// Create a shader with a constant color output, using the given standard libraries
32 /// for code generation.
34  DocumentPtr stdLib,
35  const string& shaderName,
36  const Color3& color);
37 
38 /// Create a shader with depth value output, using the given standard libraries
39 /// for code generation.
41  DocumentPtr stdLib,
42  const string& shaderName);
43 
44 /// Create a shader that generates a look-up table for directional albedo, using
45 /// the given standard libraries for code generation.
47  DocumentPtr stdLib,
48  const string& shaderName);
49 
50 /// Create a blur shader, using the given standard libraries for code generation.
52  DocumentPtr stdLib,
53  const string& shaderName,
54  const string& filterType,
55  float filterSize);
56 
57 /// @}
58 /// @name User Interface Utilities
59 /// @{
60 
61 /// Set of possible UI properties for an element
63 {
64  /// UI name
65  string uiName;
66 
67  /// UI folder
68  string uiFolder;
69 
70  /// Enumeration
72 
73  /// Enumeration Values
74  vector<ValuePtr> enumerationValues;
75 
76  /// UI minimum value
78 
79  /// UI maximum value
81 
82  /// UI soft minimum value
84 
85  /// UI soft maximum value
87 
88  /// UI step value
90 
91  /// UI advanced element
92  bool uiAdvanced = false;
93 };
94 
95 /// Get the UI properties for a given input element and target.
96 /// Returns the number of properties found.
97 MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string& target, UIProperties& uiProperties);
98 
99 /// Interface for holding the UI properties associated shader port
101 {
102  string label;
103  ShaderPort* variable = nullptr;
105 };
106 
107 /// A grouping of property items by name
108 using UIPropertyGroup = std::multimap<string, UIPropertyItem>;
109 
110 /// Utility to group UI properties items based on Element group name from a VariableBlock.
111 /// Returns a list of named and unnamed groups.
113  UIPropertyGroup& unnamedGroups, const string& pathSeparator);
114 
115 /// @}
116 
118 
119 #endif
Interface for holding the UI properties associated shader port.
Definition: Util.h:100
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
vector< string > StringVec
A vector of strings.
Definition: Library.h:57
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)
ValuePtr uiMin
UI minimum value.
Definition: Util.h:77
vector< ValuePtr > enumerationValues
Enumeration Values.
Definition: Util.h:74
MX_RENDER_API void createUIPropertyGroups(DocumentPtr doc, const VariableBlock &block, UIPropertyGroup &groups, UIPropertyGroup &unnamedGroups, const string &pathSeparator)
Set of possible UI properties for an element.
Definition: Util.h:62
MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string &target, UIProperties &uiProperties)
ValuePtr uiMax
UI maximum value.
Definition: Util.h:80
ValuePtr uiSoftMax
UI soft maximum value.
Definition: Util.h:86
string uiName
UI name.
Definition: Util.h:65
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
GLenum target
Definition: glcorearb.h:1667
MX_RENDER_API const Color3 DEFAULT_SCREEN_COLOR_LIN_REC709
MX_RENDER_API ShaderPtr createConstantShader(GenContext &context, DocumentPtr stdLib, const string &shaderName, const Color3 &color)
string uiFolder
UI folder.
Definition: Util.h:68
shared_ptr< Input > InputPtr
A shared pointer to an Input.
Definition: Interface.h:31
MX_RENDER_API ShaderPtr createDepthShader(GenContext &context, DocumentPtr stdLib, const string &shaderName)
MATERIALX_NAMESPACE_BEGIN MX_RENDER_API const Color3 DEFAULT_SCREEN_COLOR_SRGB
ValuePtr uiStep
UI step value.
Definition: Util.h:89
#define MX_RENDER_API
Definition: Export.h:18
GLuint color
Definition: glcorearb.h:1261
MX_RENDER_API ShaderPtr createShader(const string &shaderName, GenContext &context, ElementPtr elem)
Create a shader for a given element.
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
StringVec enumeration
Enumeration.
Definition: Util.h:71
UIProperties ui
Definition: Util.h:104
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
ValuePtr uiSoftMin
UI soft minimum value.
Definition: Util.h:83
std::multimap< string, UIPropertyItem > UIPropertyGroup
A grouping of property items by name.
Definition: Util.h:108
string label
Definition: Util.h:102