Skip to content
On this page

class ShaderGenerator

Given a material, the shader data class keeps the relevant shader data and is able to generate a GLSL/HLSL shader.

Properties

PropertyDescription
GenerateFullShaderThe GenerateFullShader flag value. If set, the shader generator will generate a full shader, and not just the material shader tree. If false, the generator will define the basic samplers, the per-fragment information and all the sampling tree functions, but not the vertex and fragment shaders, that the user will have to generate manually. This is useful for custom shader integration.
GenerateTextureSamplerDataThe GenerateTextureSamplerData flag value. If set, the shader generator will generate sampler registers and uniforms (HLSL: map_[x] values, state_[x]). If not set, the user will need to define them manually. As a help, the code is still generated, but commented out. This flag only applies to when the shader only generates the shading sampling tree, and is ignored if the GenerateFullShader is set.
IdentifersPrefixThe prefix for all global identifiers.
MaterialThe material, for which to create a shader.
NameThe name of the ShaderGenerator object. (Inherited from Object)

Methods

MethodDescription
AddObserverAdds a user-defined observer object to the interface, that will receive events from the interface. (Inherited from Object)
GenerateShaderDataGenerates a shader, given a material that uses shading node networks. To generate the actual shader code, use GetHLSLCode, GetGLSLVertexCode and GetGLSLFragmentCode.
GetClassGet the name of the ShaderGenerator class. (Inherited from Object)
GetGLSLFragmentCodeReturns a string containing the GLSL fragment shader GenerateShader must have been called prior to this call.
GetGLSLVertexCodeReturns a string containing the GLSL vertex shader GenerateShader must have been called prior to this call. Note: If GenerateFullShader is set to false, this code will be empty, as the code generated is only used by the fragment shader.
GetHLSLCodeReturns a string containing the HLSL shader code. GenerateShader must have been called prior to this call.
GetShaderInputTexturePathGet a specific path from the list of unique paths. See notes of GetShaderInputTexturePathsCount for more documentation on usage.
GetShaderInputTexturePathsCountThe number of unique texture paths used in the material. For the shader to use these textures, they are required to be uploaded to the texture channel corresponding to their position in the array. The shader will generate these sampler variables with the naming convention "map_i" (i : the array index of the texture). GenerateShader must have been called prior to this call. Enumerate 0 to Count, and use GetShaderInputTexturePath to retrieve a specific path.
GetShaderInputUVIndexReturns the index that is set for the specific input UV set. If the UV set is not used by the generated shader, the returned value is -1. Note that the UV set name must match exactly, including case.
GetShaderInputUVSetGet a specific set from the list of unique sets. See notes of GetShaderInputUVSetsCount for more documentation on usage.
GetShaderInputUVSetsCountThe number of unique UV sets used in the material. For the shader to use these UV sets, they are required to be uploaded as texture coordinates corresponding to their position in the array. The shader will generate the texcoords variables with the naming convention "tex_i" (i : the array index of the UV set). GenerateShader must have been called prior to this call.
GetShaderInputVertexColorGet a specific set from the list of unique sets. See notes of GetShaderInputVertexColorsCount for more documentation on usage.
GetShaderInputVertexColorsCountThe number of unique vertex colors used in the material. For the shader to use these vertex colors, they are required to be uploaded as vertex color corresponding to their position in the array. The shader will generate the vertex color variables with the naming convention "vertexcolor_i" (i : the array index of the vertex color). GenerateShader must have been called prior to this call.
GetShaderInputVertexColorsIndexReturns the index that is set for the specific input vertex color set. If the vertex color set is not used by the generated shader, the returned value is -1. Note that the vertex color set name must match exactly, including case.
IsAReturns true if ShaderGenerator is a or is a descendant of the class named as the type parameter. (Inherited from Object)
IsNullReturns true if the ShaderGenerator object is invalid. (Inherited from Object)
IsSameObjectAsReturns true if the ShaderGenerator object is valid. (Inherited from Object)
NonNullReturns true if the ShaderGenerator object is valid. (Inherited from Object)
PrintInfoPrints the content/info of the ShaderGenerator object to the log. (Inherited from Object)
RemoveObserverRemoves a previously added observer object. (Inherited from Object)
UnloadDataUnloads all shader data and resets it.

Static methods

MethodDescription
IsClassAReturns true if the class is a or is a descendant of the class named as the type parameter. (Inherited from Object)
SafeCastSafeCast makes sure the input object is of a class that can be cast into spShaderGenerator, and if this is the case, returns the object cast into spShaderGenerator. (Inherited from Object)

Properties details

GenerateFullShader

The GenerateFullShader flag value. If set, the shader generator will generate a full shader, and not just the material shader tree. If false, the generator will define the basic samplers, the per-fragment information and all the sampling tree functions, but not the vertex and fragment shaders, that the user will have to generate manually. This is useful for custom shader integration.

GenerateTextureSamplerData

The GenerateTextureSamplerData flag value. If set, the shader generator will generate sampler registers and uniforms (HLSL: map_[x] values, state_[x]). If not set, the user will need to define them manually. As a help, the code is still generated, but commented out. This flag only applies to when the shader only generates the shading sampling tree, and is ignored if the GenerateFullShader is set.

IdentifersPrefix

The prefix for all global identifiers.

Material

The material, for which to create a shader.

Name

The name of the ShaderGenerator object. (Inherited from Object)

Methods details

AddObserver

Adds a user-defined observer object to the interface, that will receive events from the interface. (Inherited from Object)

GenerateShaderData

Generates a shader, given a material that uses shading node networks. To generate the actual shader code, use GetHLSLCode, GetGLSLVertexCode and GetGLSLFragmentCode.

GetClass

Get the name of the ShaderGenerator class. (Inherited from Object)

GetGLSLFragmentCode

Returns a string containing the GLSL fragment shader GenerateShader must have been called prior to this call.

GetGLSLVertexCode

Returns a string containing the GLSL vertex shader GenerateShader must have been called prior to this call. Note: If GenerateFullShader is set to false, this code will be empty, as the code generated is only used by the fragment shader.

GetHLSLCode

Returns a string containing the HLSL shader code. GenerateShader must have been called prior to this call.

GetShaderInputTexturePath

Get a specific path from the list of unique paths. See notes of GetShaderInputTexturePathsCount for more documentation on usage.

GetShaderInputTexturePathsCount

The number of unique texture paths used in the material. For the shader to use these textures, they are required to be uploaded to the texture channel corresponding to their position in the array. The shader will generate these sampler variables with the naming convention "map_i" (i : the array index of the texture). GenerateShader must have been called prior to this call. Enumerate 0 to Count, and use GetShaderInputTexturePath to retrieve a specific path.

GetShaderInputUVIndex

Returns the index that is set for the specific input UV set. If the UV set is not used by the generated shader, the returned value is -1. Note that the UV set name must match exactly, including case.

GetShaderInputUVSet

Get a specific set from the list of unique sets. See notes of GetShaderInputUVSetsCount for more documentation on usage.

GetShaderInputUVSetsCount

The number of unique UV sets used in the material. For the shader to use these UV sets, they are required to be uploaded as texture coordinates corresponding to their position in the array. The shader will generate the texcoords variables with the naming convention "tex_i" (i : the array index of the UV set). GenerateShader must have been called prior to this call.

GetShaderInputVertexColor

Get a specific set from the list of unique sets. See notes of GetShaderInputVertexColorsCount for more documentation on usage.

GetShaderInputVertexColorsCount

The number of unique vertex colors used in the material. For the shader to use these vertex colors, they are required to be uploaded as vertex color corresponding to their position in the array. The shader will generate the vertex color variables with the naming convention "vertexcolor_i" (i : the array index of the vertex color). GenerateShader must have been called prior to this call.

GetShaderInputVertexColorsIndex

Returns the index that is set for the specific input vertex color set. If the vertex color set is not used by the generated shader, the returned value is -1. Note that the vertex color set name must match exactly, including case.

IsA

Returns true if ShaderGenerator is a or is a descendant of the class named as the type parameter. (Inherited from Object)

IsNull

Returns true if the ShaderGenerator object is invalid. (Inherited from Object)

IsSameObjectAs

Returns true if the ShaderGenerator object is valid. (Inherited from Object)

NonNull

Returns true if the ShaderGenerator object is valid. (Inherited from Object)

PrintInfo

Prints the content/info of the ShaderGenerator object to the log. (Inherited from Object)

RemoveObserver

Removes a previously added observer object. (Inherited from Object)

UnloadData

Unloads all shader data and resets it.

Static methods details

IsClassA

Returns true if the class is a or is a descendant of the class named as the type parameter. (Inherited from Object)

SafeCast

SafeCast makes sure the input object is of a class that can be cast into spShaderGenerator, and if this is the case, returns the object cast into spShaderGenerator. (Inherited from Object)