6#ifndef MATERIALX_HWSHADERGENERATOR_H
7#define MATERIALX_HWSHADERGENERATOR_H
17MATERIALX_NAMESPACE_BEGIN
87extern MX_GENSHADER_API
const string T_IN_NORMAL;
88extern MX_GENSHADER_API
const string T_IN_TANGENT;
89extern MX_GENSHADER_API
const string T_IN_BITANGENT;
90extern MX_GENSHADER_API
const string T_IN_TEXCOORD;
91extern MX_GENSHADER_API
const string T_IN_GEOMPROP;
92extern MX_GENSHADER_API
const string T_IN_COLOR;
93extern MX_GENSHADER_API
const string T_POSITION_WORLD;
94extern MX_GENSHADER_API
const string T_NORMAL_WORLD;
95extern MX_GENSHADER_API
const string T_TANGENT_WORLD;
96extern MX_GENSHADER_API
const string T_BITANGENT_WORLD;
97extern MX_GENSHADER_API
const string T_POSITION_OBJECT;
98extern MX_GENSHADER_API
const string T_NORMAL_OBJECT;
99extern MX_GENSHADER_API
const string T_TANGENT_OBJECT;
100extern MX_GENSHADER_API
const string T_BITANGENT_OBJECT;
101extern MX_GENSHADER_API
const string T_TEXCOORD;
102extern MX_GENSHADER_API
const string T_COLOR;
103extern MX_GENSHADER_API
const string T_WORLD_MATRIX;
104extern MX_GENSHADER_API
const string T_WORLD_INVERSE_MATRIX;
105extern MX_GENSHADER_API
const string T_WORLD_TRANSPOSE_MATRIX;
106extern MX_GENSHADER_API
const string T_WORLD_INVERSE_TRANSPOSE_MATRIX;
107extern MX_GENSHADER_API
const string T_VIEW_MATRIX;
108extern MX_GENSHADER_API
const string T_VIEW_INVERSE_MATRIX;
109extern MX_GENSHADER_API
const string T_VIEW_TRANSPOSE_MATRIX;
110extern MX_GENSHADER_API
const string T_VIEW_INVERSE_TRANSPOSE_MATRIX;
111extern MX_GENSHADER_API
const string T_PROJ_MATRIX;
112extern MX_GENSHADER_API
const string T_PROJ_INVERSE_MATRIX;
113extern MX_GENSHADER_API
const string T_PROJ_TRANSPOSE_MATRIX;
114extern MX_GENSHADER_API
const string T_PROJ_INVERSE_TRANSPOSE_MATRIX;
115extern MX_GENSHADER_API
const string T_WORLD_VIEW_MATRIX;
116extern MX_GENSHADER_API
const string T_VIEW_PROJECTION_MATRIX;
117extern MX_GENSHADER_API
const string T_WORLD_VIEW_PROJECTION_MATRIX;
118extern MX_GENSHADER_API
const string T_VIEW_POSITION;
119extern MX_GENSHADER_API
const string T_VIEW_DIRECTION;
120extern MX_GENSHADER_API
const string T_FRAME;
121extern MX_GENSHADER_API
const string T_TIME;
122extern MX_GENSHADER_API
const string T_GEOMPROP;
123extern MX_GENSHADER_API
const string T_ALPHA_THRESHOLD;
124extern MX_GENSHADER_API
const string T_NUM_ACTIVE_LIGHT_SOURCES;
125extern MX_GENSHADER_API
const string T_ENV_MATRIX;
126extern MX_GENSHADER_API
const string T_ENV_RADIANCE;
127extern MX_GENSHADER_API
const string T_ENV_RADIANCE_MIPS;
128extern MX_GENSHADER_API
const string T_ENV_RADIANCE_SAMPLES;
129extern MX_GENSHADER_API
const string T_ENV_IRRADIANCE;
130extern MX_GENSHADER_API
const string T_ENV_LIGHT_INTENSITY;
131extern MX_GENSHADER_API
const string T_ENV_PREFILTER_MIP;
132extern MX_GENSHADER_API
const string T_REFRACTION_TWO_SIDED;
133extern MX_GENSHADER_API
const string T_ALBEDO_TABLE;
134extern MX_GENSHADER_API
const string T_ALBEDO_TABLE_SIZE;
135extern MX_GENSHADER_API
const string T_AMB_OCC_MAP;
136extern MX_GENSHADER_API
const string T_AMB_OCC_GAIN;
137extern MX_GENSHADER_API
const string T_SHADOW_MAP;
138extern MX_GENSHADER_API
const string T_SHADOW_MATRIX;
139extern MX_GENSHADER_API
const string T_VERTEX_DATA_INSTANCE;
140extern MX_GENSHADER_API
const string T_LIGHT_DATA_INSTANCE;
145extern MX_GENSHADER_API
const string IN_NORMAL;
146extern MX_GENSHADER_API
const string IN_TANGENT;
147extern MX_GENSHADER_API
const string IN_BITANGENT;
148extern MX_GENSHADER_API
const string IN_TEXCOORD;
149extern MX_GENSHADER_API
const string IN_GEOMPROP;
150extern MX_GENSHADER_API
const string IN_COLOR;
151extern MX_GENSHADER_API
const string POSITION_WORLD;
152extern MX_GENSHADER_API
const string NORMAL_WORLD;
153extern MX_GENSHADER_API
const string TANGENT_WORLD;
154extern MX_GENSHADER_API
const string BITANGENT_WORLD;
155extern MX_GENSHADER_API
const string POSITION_OBJECT;
156extern MX_GENSHADER_API
const string NORMAL_OBJECT;
157extern MX_GENSHADER_API
const string TANGENT_OBJECT;
158extern MX_GENSHADER_API
const string BITANGENT_OBJECT;
159extern MX_GENSHADER_API
const string TEXCOORD;
160extern MX_GENSHADER_API
const string COLOR;
161extern MX_GENSHADER_API
const string WORLD_MATRIX;
162extern MX_GENSHADER_API
const string WORLD_INVERSE_MATRIX;
163extern MX_GENSHADER_API
const string WORLD_TRANSPOSE_MATRIX;
164extern MX_GENSHADER_API
const string WORLD_INVERSE_TRANSPOSE_MATRIX;
165extern MX_GENSHADER_API
const string VIEW_MATRIX;
166extern MX_GENSHADER_API
const string VIEW_INVERSE_MATRIX;
167extern MX_GENSHADER_API
const string VIEW_TRANSPOSE_MATRIX;
168extern MX_GENSHADER_API
const string VIEW_INVERSE_TRANSPOSE_MATRIX;
169extern MX_GENSHADER_API
const string PROJ_MATRIX;
170extern MX_GENSHADER_API
const string PROJ_INVERSE_MATRIX;
171extern MX_GENSHADER_API
const string PROJ_TRANSPOSE_MATRIX;
172extern MX_GENSHADER_API
const string PROJ_INVERSE_TRANSPOSE_MATRIX;
173extern MX_GENSHADER_API
const string WORLD_VIEW_MATRIX;
174extern MX_GENSHADER_API
const string VIEW_PROJECTION_MATRIX;
175extern MX_GENSHADER_API
const string WORLD_VIEW_PROJECTION_MATRIX;
176extern MX_GENSHADER_API
const string VIEW_POSITION;
177extern MX_GENSHADER_API
const string VIEW_DIRECTION;
178extern MX_GENSHADER_API
const string FRAME;
179extern MX_GENSHADER_API
const string TIME;
180extern MX_GENSHADER_API
const string GEOMPROP;
181extern MX_GENSHADER_API
const string ALPHA_THRESHOLD;
182extern MX_GENSHADER_API
const string NUM_ACTIVE_LIGHT_SOURCES;
183extern MX_GENSHADER_API
const string ENV_MATRIX;
184extern MX_GENSHADER_API
const string ENV_RADIANCE;
185extern MX_GENSHADER_API
const string ENV_RADIANCE_MIPS;
186extern MX_GENSHADER_API
const string ENV_RADIANCE_SAMPLES;
187extern MX_GENSHADER_API
const string ENV_IRRADIANCE;
188extern MX_GENSHADER_API
const string ENV_LIGHT_INTENSITY;
189extern MX_GENSHADER_API
const string ENV_PREFILTER_MIP;
190extern MX_GENSHADER_API
const string REFRACTION_TWO_SIDED;
191extern MX_GENSHADER_API
const string ALBEDO_TABLE;
192extern MX_GENSHADER_API
const string ALBEDO_TABLE_SIZE;
193extern MX_GENSHADER_API
const string AMB_OCC_MAP;
194extern MX_GENSHADER_API
const string AMB_OCC_GAIN;
195extern MX_GENSHADER_API
const string SHADOW_MAP;
196extern MX_GENSHADER_API
const string SHADOW_MATRIX;
197extern MX_GENSHADER_API
const string VERTEX_DATA_INSTANCE;
198extern MX_GENSHADER_API
const string LIGHT_DATA_INSTANCE;
199extern MX_GENSHADER_API
const string LIGHT_DATA_MAX_LIGHT_SOURCES;
203extern MX_GENSHADER_API
const string VERTEX_DATA;
204extern MX_GENSHADER_API
const string PRIVATE_UNIFORMS;
205extern MX_GENSHADER_API
const string PUBLIC_UNIFORMS;
206extern MX_GENSHADER_API
const string LIGHT_DATA;
207extern MX_GENSHADER_API
const string PIXEL_OUTPUTS;
210extern MX_GENSHADER_API
const string DIR_N;
211extern MX_GENSHADER_API
const string DIR_L;
212extern MX_GENSHADER_API
const string DIR_V;
213extern MX_GENSHADER_API
const string WORLD_POSITION;
214extern MX_GENSHADER_API
const string OCCLUSION;
221extern MX_GENSHADER_API
const string USER_DATA_BINDING_CONTEXT;
227extern MX_GENSHADER_API
const string VERTEX;
249 return std::make_shared<HwLightShaders>();
255 _shaders[type] = shader;
261 _shaders.erase(type);
274 auto it = _shaders.find(type);
275 return it != _shaders.end() ? it->second.get() :
nullptr;
279 const std::unordered_map<unsigned int, ShaderNodePtr>&
get()
const
285 std::unordered_map<unsigned int, ShaderNodePtr> _shaders;
329 static const string CLOSURE_CONTEXT_SUFFIX_TRANSMISSION;
330 static const string CLOSURE_CONTEXT_SUFFIX_INDIRECT;
367 static const string INDEX;
368 static const string GEOMPROP;
379 virtual void initialize() = 0;
389 ShaderStage& stage,
const std::string& structInstanceName,
390 const std::string& arraySuffix = EMPTY_STRING) = 0;
393MATERIALX_NAMESPACE_END
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
Context classes for shader generation.
shared_ptr< class HwShaderGenerator > HwShaderGeneratorPtr
Shared pointer to a HwShaderGenerator.
Definition: HwShaderGenerator.h:237
shared_ptr< class HwResourceBindingContext > HwResourceBindingContextPtr
Shared pointer to a HwResourceBindingContext.
Definition: HwShaderGenerator.h:239
shared_ptr< class HwLightShaders > HwLightShadersPtr
Shared pointer to a HwLightShaders.
Definition: HwShaderGenerator.h:235
Macros for declaring imported and exported symbols.
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
Base shader generator class.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
Definition: Syntax.h:27
Class representing a context for closure evaluation.
Definition: GenContext.h:248
A context class for shader generation.
Definition: GenContext.h:31
Base class for custom user data needed during shader generation.
Definition: GenUserData.h:27
Definition: HwShaderGenerator.h:349
bool isEditable(const ShaderInput &input) const override
Returns true if an input is editable by users.
static const string SPACE
Internal string constants.
Definition: HwShaderGenerator.h:366
Hardware light shader user data.
Definition: HwShaderGenerator.h:244
void bind(unsigned int type, ShaderNodePtr shader)
Bind a light shader to a light type id.
Definition: HwShaderGenerator.h:253
const ShaderNode * get(unsigned int type) const
Return the light shader bound to the given light type, or nullptr if not light shader is bound to thi...
Definition: HwShaderGenerator.h:272
const std::unordered_map< unsigned int, ShaderNodePtr > & get() const
Return the map of bound light shaders.
Definition: HwShaderGenerator.h:279
static HwLightShadersPtr create()
Create and return a new instance.
Definition: HwShaderGenerator.h:247
void clear()
Clear all light shaders previously bound.
Definition: HwShaderGenerator.h:265
void unbind(unsigned int type)
Unbind a light shader previously bound to a light type id.
Definition: HwShaderGenerator.h:259
Class representing a context for resource binding for hardware resources.
Definition: HwShaderGenerator.h:374
Base class for shader generators targeting HW rendering.
Definition: HwShaderGenerator.h:291
static const string CLOSURE_CONTEXT_SUFFIX_REFLECTION
String constants for closure context suffixes.
Definition: HwShaderGenerator.h:328
ClosureContext _defDefault
Closure contexts for defining closure functions.
Definition: HwShaderGenerator.h:339
static void unbindLightShader(unsigned int lightTypeId, GenContext &context)
Unbind a light shader previously bound to the given light type id.
virtual ShaderPtr createShader(const string &name, ElementPtr element, GenContext &context) const
Create and initialize a new HW shader for shader generation.
virtual void addStageLightingUniforms(GenContext &context, ShaderStage &stage) const
Emit code for active light count definitions and uniforms.
static void bindLightShader(const NodeDef &nodeDef, unsigned int lightTypeId, GenContext &context)
Bind a light shader to a light type id, for usage in surface shaders created by the generator.
static void unbindLightShaders(GenContext &context)
Unbind all light shaders previously bound.
void emitFunctionCall(const ShaderNode &node, GenContext &context, ShaderStage &stage) const override
Add the function call for a single node.
ClosureContextType
Types of closure contexts for HW.
Definition: HwShaderGenerator.h:319
virtual string getVertexDataPrefix(const VariableBlock &vertexData) const =0
Determine the prefix of vertex data variables.
void getClosureContexts(const ShaderNode &node, vector< ClosureContext * > &cct) const override
Return the closure contexts defined for the given node.
A node definition element within a Document.
Definition: Definition.h:82
Base class for shader generators All third-party shader generators should derive from this class.
Definition: ShaderGenerator.h:31
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:320
Class handling the shader generation implementation for a node.
Definition: ShaderNodeImpl.h:32
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:139
A block of variables in a shader stage.
Definition: ShaderStage.h:61
HW specific identifiers.
Definition: HwShaderGenerator.h:84
MX_GENSHADER_API const string IN_POSITION
Default names for identifiers.
MX_GENSHADER_API const string T_IN_POSITION
Token identifiers.
MX_GENSHADER_API const string ATTR_TRANSPARENT
Attribute names.
MX_GENSHADER_API const string VERTEX_INPUTS
Variable blocks names.
MX_GENSHADER_API const string DIR_N
Variable names for lighting parameters.
MX_GENSHADER_API const string USER_DATA_LIGHT_SHADERS
User data names.