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 shader that generates a prefiltered environment map.
52  DocumentPtr stdLib,
53  const string& shaderName);
54 
55 /// Create a blur shader, using the given standard libraries for code generation.
57  DocumentPtr stdLib,
58  const string& shaderName,
59  const string& filterType,
60  float filterSize);
61 
62 /// @}
63 /// @name User Interface Utilities
64 /// @{
65 
66 /// Set of possible UI properties for an element
68 {
69  /// UI name
70  string uiName;
71 
72  /// UI folder
73  string uiFolder;
74 
75  /// Enumeration
77 
78  /// Enumeration Values
79  vector<ValuePtr> enumerationValues;
80 
81  /// UI minimum value
83 
84  /// UI maximum value
86 
87  /// UI soft minimum value
89 
90  /// UI soft maximum value
92 
93  /// UI step value
95 
96  /// UI advanced element
97  bool uiAdvanced = false;
98 };
99 
100 /// Get the UI properties for a given input element and target.
101 /// Returns the number of properties found.
102 MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string& target, UIProperties& uiProperties);
103 
104 /// Interface for holding the UI properties associated shader port
106 {
107  string label;
108  ShaderPort* variable = nullptr;
110 };
111 
112 /// A grouping of property items by name
113 using UIPropertyGroup = std::multimap<string, UIPropertyItem>;
114 
115 /// Utility to group UI properties items based on Element group name from a VariableBlock.
116 /// Returns a list of named and unnamed groups.
118  UIPropertyGroup& unnamedGroups, const string& pathSeparator);
119 
120 /// @}
121 
123 
124 #endif
Interface for holding the UI properties associated shader port.
Definition: Util.h:105
#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:82
vector< ValuePtr > enumerationValues
Enumeration Values.
Definition: Util.h:79
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:67
MX_RENDER_API unsigned int getUIProperties(InputPtr input, const string &target, UIProperties &uiProperties)
ValuePtr uiMax
UI maximum value.
Definition: Util.h:85
ValuePtr uiSoftMax
UI soft maximum value.
Definition: Util.h:91
string uiName
UI name.
Definition: Util.h:70
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:73
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:94
#define MX_RENDER_API
Definition: Export.h:18
GLuint color
Definition: glcorearb.h:1261
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.
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:76
UIProperties ui
Definition: Util.h:109
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
ValuePtr uiSoftMin
UI soft minimum value.
Definition: Util.h:88
std::multimap< string, UIPropertyItem > UIPropertyGroup
A grouping of property items by name.
Definition: Util.h:113
string label
Definition: Util.h:107