HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenOptions.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_GENOPTIONS_H
7 #define MATERIALX_GENOPTIONS_H
8 
9 /// @file
10 /// Shader generation options class
11 
13 
14 #include <MaterialXFormat/File.h>
15 
17 
18 /// Type of shader interface to be generated
20 {
21  /// Create a complete interface with uniforms for all
22  /// editable inputs on all nodes used by the shader.
23  /// This interface makes the shader fully editable by
24  /// value without requiring any rebuilds.
25  /// This is the default interface type.
27 
28  /// Create a reduced interface with uniforms only for
29  /// the inputs that has been declared in the shaders
30  /// nodedef interface. If values on other inputs are
31  /// changed the shader needs to be rebuilt.
33 };
34 
35 /// Method to use for specular environment lighting
37 {
38  /// Do not use specular environment maps
40 
41  /// Use Filtered Importance Sampling for
42  /// specular environment/indirect lighting.
44 
45  /// Use pre-filtered environment maps for
46  /// specular environment/indirect lighting.
48 };
49 
50 /// Method to use for directional albedo evaluation
52 {
53  /// Use an analytic approximation for directional albedo.
55 
56  /// Use a table look-up for directional albedo.
58 
59  /// Use Monte Carlo integration for directional albedo.
61 };
62 
63 /// Method to use for transmission rendering
65 {
66  /// Use a refraction approximation for transmission rendering
68 
69  /// Use opacity for transmission rendering
71 };
72 
73 /// @class GenOptions
74 /// Class holding options to configure shader generation.
76 {
77  public:
79  shaderInterfaceType(SHADER_INTERFACE_COMPLETE),
80  fileTextureVerticalFlip(false),
81  addUpstreamDependencies(true),
82  libraryPrefix("libraries"),
83  emitColorTransforms(true),
84  elideConstantNodes(true),
85  premultipliedBsdfAdd(false),
86  distributeLayerOverBsdfMix(false),
87  hwTransparency(false),
88  hwSpecularEnvironmentMethod(SPECULAR_ENVIRONMENT_FIS),
89  hwDirectionalAlbedoMethod(DIRECTIONAL_ALBEDO_ANALYTIC),
90  hwTransmissionRenderMethod(TRANSMISSION_REFRACTION),
91  hwAiryFresnelIterations(2),
92  hwSrgbEncodeOutput(false),
93  hwWriteDepthMoments(false),
94  hwShadowMap(false),
95  hwAmbientOcclusion(false),
96  hwMaxActiveLightSources(3),
97  hwNormalizeUdimTexCoords(false),
98  hwWriteAlbedoTable(false),
99  hwWriteEnvPrefilter(false),
100  hwImplicitBitangents(true),
101  oslImplicitSurfaceShaderConversion(true),
102  oslConnectCiWrapper(false)
103  {
104  }
105  virtual ~GenOptions() { }
106 
107  // TODO: Add options for:
108  // - shader gen optimization level
109  // - graph flattening or not
110 
111  /// Sets the type of shader interface to be generated
113 
114  /// If true the y-component of texture coordinates used for sampling
115  /// file textures will be flipped before sampling. This can be used if
116  /// file textures need to be flipped vertically to match the target's
117  /// texture space convention. By default this option is false.
119 
120  /// An optional override for the target color space.
121  /// Shader fragments will be generated to transform
122  /// input values and textures into this color space.
124 
125  /// Define the target distance unit.
126  /// Shader fragments will be generated to transform
127  /// input distance values to the given unit.
129 
130  /// Sets whether to include upstream dependencies
131  /// for the element to generate a shader for.
133 
134  /// The standard library prefix, which will be applied to
135  /// calls to emitLibraryInclude during code generation.
136  /// Defaults to "libraries".
138 
139  /// Enable emitting colorspace transform code if a color management
140  /// system is defined. Defaults to true.
142 
143  /// Enable eliding constant nodes. Defaults to true.
145 
146  /// Enable replacing BSDF mix nodes with premultiplied add nodes.
147  /// This folds the mix weight into each BSDF's weight input, enabling
148  /// hardware shading languages to skip BSDF evaluation via dynamic
149  /// branching when the weight is zero. Defaults to false.
151 
152  /// Enable distributing layer operations over mix nodes.
153  /// Transforms layer(mix(A, B, w), C) into mix(layer(A, C), layer(B, C), w)
154  /// for backends with limited layering capabilities. Defaults to false.
156 
157  /// Sets if transparency is needed or not for HW shaders.
158  /// If a surface shader has potential of being transparent
159  /// this must be set to true, otherwise no transparency
160  /// code fragments will be generated for the shader and
161  /// the surface will be fully opaque.
163 
164  /// Sets the method to use for specular environment lighting
165  /// for HW shader targets.
167 
168  /// Sets the method to use for directional albedo evaluation
169  /// for HW shader targets.
171 
172  /// Sets the method to use for transmission rendering
173  /// for HW shader targets.
175 
176  /// Sets the number of iterations for Airy Fresnel reflection calculations.
177  /// Higher values provide more accurate thin-film interference patterns
178  /// but increase computational cost. Defaults to 2.
180 
181  /// Enables an sRGB encoding for the color output on HW shader targets.
182  /// Defaults to false.
184 
185  /// Enables the writing of depth moments for HW shader targets.
186  /// Defaults to false.
188 
189  /// Enables shadow mapping for HW shader targets.
190  /// Defaults to false.
192 
193  /// Enables ambient occlusion rendering for HW shader targets.
194  /// Defaults to false.
196 
197  /// Sets the maximum number of light sources that can
198  /// be active at once.
200 
201  /// Sets whether to transform texture coordinates to normalize
202  /// uv space when UDIMs images are bound to an image. Can be
203  /// enabled for when texture atlas generation is performed to
204  /// compress a set of UDIMs into a single normalized image for
205  /// hardware rendering.
207 
208  /// Enables the writing of a directional albedo table.
209  /// Defaults to false.
211 
212  /// Enables the generation of a prefiltered environment map.
213  /// Defaults to false.
215 
216  /// Calculate fallback bitangents from existing normals and tangents
217  /// inside the bitangent node.
219 
220  // Enables OSL conversion of surfaceshader struct to closure color.
221  // Defaults to true.
223 
224  // Enables an OSL node that adds the root's output to the Ci variable
225  // for OSL targets.
226  // Defaults to false.
228 };
229 
231 
232 #endif
ShaderInterfaceType
Type of shader interface to be generated.
Definition: GenOptions.h:19
HwDirectionalAlbedoMethod hwDirectionalAlbedoMethod
Definition: GenOptions.h:170
Definition: File.h:26
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
bool fileTextureVerticalFlip
Definition: GenOptions.h:118
bool emitColorTransforms
Definition: GenOptions.h:141
HwDirectionalAlbedoMethod
Method to use for directional albedo evaluation.
Definition: GenOptions.h:51
bool premultipliedBsdfAdd
Definition: GenOptions.h:150
Use opacity for transmission rendering.
Definition: GenOptions.h:70
HwTransmissionRenderMethod
Method to use for transmission rendering.
Definition: GenOptions.h:64
ShaderInterfaceType shaderInterfaceType
Sets the type of shader interface to be generated.
Definition: GenOptions.h:112
unsigned int hwAiryFresnelIterations
Definition: GenOptions.h:179
bool hwWriteDepthMoments
Definition: GenOptions.h:187
virtual ~GenOptions()
Definition: GenOptions.h:105
#define MX_GENSHADER_API
Definition: Export.h:18
unsigned int hwMaxActiveLightSources
Definition: GenOptions.h:199
string targetColorSpaceOverride
Definition: GenOptions.h:123
Use an analytic approximation for directional albedo.
Definition: GenOptions.h:54
bool hwNormalizeUdimTexCoords
Definition: GenOptions.h:206
Use a refraction approximation for transmission rendering.
Definition: GenOptions.h:67
HwSpecularEnvironmentMethod hwSpecularEnvironmentMethod
Definition: GenOptions.h:166
bool hwTransparency
Definition: GenOptions.h:162
bool hwWriteAlbedoTable
Definition: GenOptions.h:210
Use Monte Carlo integration for directional albedo.
Definition: GenOptions.h:60
HwSpecularEnvironmentMethod
Method to use for specular environment lighting.
Definition: GenOptions.h:36
bool distributeLayerOverBsdfMix
Definition: GenOptions.h:155
bool hwWriteEnvPrefilter
Definition: GenOptions.h:214
bool hwImplicitBitangents
Definition: GenOptions.h:218
bool hwSrgbEncodeOutput
Definition: GenOptions.h:183
bool elideConstantNodes
Enable eliding constant nodes. Defaults to true.
Definition: GenOptions.h:144
bool addUpstreamDependencies
Definition: GenOptions.h:132
bool hwAmbientOcclusion
Definition: GenOptions.h:195
HwTransmissionRenderMethod hwTransmissionRenderMethod
Definition: GenOptions.h:174
Use a table look-up for directional albedo.
Definition: GenOptions.h:57
FilePath libraryPrefix
Definition: GenOptions.h:137
bool hwShadowMap
Definition: GenOptions.h:191
bool oslImplicitSurfaceShaderConversion
Definition: GenOptions.h:222
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
Do not use specular environment maps.
Definition: GenOptions.h:39
string targetDistanceUnit
Definition: GenOptions.h:128
bool oslConnectCiWrapper
Definition: GenOptions.h:227