class TMaterialParameters

template<bool IsRenderProxy>

Common code that may be specialized for both MaterialParams and render::MaterialParams.

Public

Constructors

TMaterialParameters<IsRenderProxy>

TMaterialParameters<IsRenderProxy>(const ShaderType &shader, u64 initialParamVersion)

Creates a new material params object and initializes enough room for parameters from the provided shader.

shader
Shader containing the information about parameters and their types.
initialParamVersion
Initial version number to assign to the parameters. Usually relevant if you are replacing an existing MaterialParams object and wish to ensure version number keeps getting incremented.

TMaterialParameters<IsRenderProxy>

TMaterialParameters<IsRenderProxy>() = default

Constructor for serialization use only.

Methods

~TMaterialParameters<IsRenderProxy>

virtual ~TMaterialParameters<IsRenderProxy>()

GetStructData

void GetStructData(const String &name, void *value, u32 size, u32 arrayIdx) const

Returns the value of a shader structure parameter with the specified name at the specified array index.

If the parameter name, index or type is not valid a warning will be logged and output value will not be retrieved.

name
Name of the shader parameter.
value
Pre-allocated buffer of bytes where the value will be retrieved.
size
Size of the buffer into which to write the value. Must match parameter struct's size.
arrayIdx
If the parameter is an array, index of the entry to access.

SetStructData

void SetStructData(const String &name, const void *value, u32 size, u32 arrayIdx)

Sets the value of a shader structure parameter with the specified name at the specified array index.

If the parameter name, index or type is not valid a warning will be logged and output value will not be retrieved.

name
Name of the shader parameter.
value
Buffer of bytes containing the new value of the structure.
size
Size of the buffer from which to retrieve the value. Must match parameter struct's size.
arrayIdx
If the parameter is an array, index of the entry to access.

GetTexture

void GetTexture(const String &name, TextureType &value, TextureSurface &surface) const

Returns the value of a shader texture parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be retrieved.

name
Name of the shader parameter.
value
Output value of the parameter.
surface
Surface describing which part of the texture is being accessed.

SetTexture

void SetTexture(const String &name, const TextureType &value, const TextureSurface &surface = TextureSurface::kComplete)

Sets the value of a shader texture parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
value
New value of the parameter.
surface
Surface describing which part of the texture is being accessed.

GetSpriteImage

void GetSpriteImage(const String &name, SpriteImageType &value) const

Returns the value of a shader texture parameter with the specified name as a sprite image.

If the parameter name or type is not valid a warning will be logged and output value will not be retrieved. If the assigned texture is not a sprite texture then this returns null and you should use one of the GetTexture() overloads instead.

name
Name of the shader parameter.
value
Output value of the parameter.

SetSpriteImage

void SetSpriteImage(const String &name, const SpriteImageType &value)

Assigns a sprite image to a shader texture parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
value
New value of the parameter.

GetStorageTexture

void GetStorageTexture(const String &name, TextureType &value, TextureSurface &surface) const

Returns the value of a shader load/store texture parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be retrieved.

name
Name of the shader parameter.
value
Output value of the parameter.
surface
Surface describing which part of the texture is being accessed.

SetStorageTexture

void SetStorageTexture(const String &name, const TextureType &value, const TextureSurface &surface)

Sets the value of a shader load/store texture parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and the value will not be set.

name
Name of the shader parameter.
value
New value of the parameter.
surface
Surface describing which part of the texture is being accessed.

GetBuffer

void GetBuffer(const String &name, BufferType &value) const

Returns the value of a shader buffer parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be retrieved.

name
Name of the shader parameter.
value
Output value of the parameter.

SetBuffer

void SetBuffer(const String &name, const BufferType &value)

Sets the value of a shader buffer parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
value
New value of the parameter.

GetSamplerState

void GetSamplerState(const String &name, SPtr<SamplerState> &value) const

Sets the value of a shader sampler state parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
value
Output value of the parameter.

SetSamplerState

void SetSamplerState(const String &name, const SPtr<SamplerState> &value)

Sets the value of a shader sampler state parameter with the specified name.

If the parameter name or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
value
New value of the parameter.

IsAnimated

bool IsAnimated(const String &name, u32 arrayIdx = 0)

Checks does the data parameter with the specified name currently contains animated data.

This could be an animation curve or a color gradient.

GetStructData

void GetStructData(const ParamData &param, void *value, u32 size, u32 arrayIdx) const

Equivalent to getStructData(const String & , u32, void*, u32) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetStructData

void SetStructData(const ParamData &param, const void *value, u32 size, u32 arrayIdx)

Equivalent to setStructData(const String & , u32, void*, u32) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetStructSize

u32 GetStructSize(const ParamData &param) const

Returns a size of a struct parameter in bytes, using the internal parameter reference.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetTexture

void GetTexture(const ParamData &param, TextureType &value, TextureSurface &surface) const

Equivalent to getTexture(const String & , HTexture & , TextureSurface & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetTexture

void SetTexture(const ParamData &param, const TextureType &value, const TextureSurface &surface = TextureSurface::kComplete)

Equivalent to setTexture(const String & , const HTexture & , const TextureSurface & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetSpriteImage

void GetSpriteImage(const ParamData &param, SpriteImageType &value) const

Equivalent to GetSpriteImage(const String & , HSpriteImage & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetSpriteImage

void SetSpriteImage(const ParamData &param, const SpriteImageType &value)

Equivalent to SetSpriteImage(const String & , const HSpriteImage & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetBuffer

void GetBuffer(const ParamData &param, BufferType &value) const

Equivalent to getBuffer(const String & , SPtr <GpuBuffer > & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetBuffer

void SetBuffer(const ParamData &param, const BufferType &value)

Equivalent to setBuffer(const String & , const SPtr <GpuBuffer > & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetStorageTexture

void GetStorageTexture(const ParamData &param, TextureType &value, TextureSurface &surface) const

Equivalent to getLoadStoreTexture(const String & , HTexture & , TextureSurface & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetStorageTexture

void SetStorageTexture(const ParamData &param, const TextureType &value, const TextureSurface &surface)

Equivalent to setLoadStoreTexture(const String & , const HTexture & , TextureSurface & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetTextureType

MateralParamTextureType GetTextureType(const ParamData &param) const

Returns the type of texture that is currently assigned to the provided parameter.

This can only be called on on texture parameters. Caller must guarantee the parameter reference is valid, is of a texture type and belongs to this object.

IsAnimated

bool IsAnimated(const ParamData &param, u32 arrayIdx) const

Checks does the provided parameter have a curve or gradient assigned.

This can only be called on data parameters. Caller must guarantee the parameter reference is valid, is of a data type and belongs to this object.

GetOwningSpriteImage

SpriteImageType GetOwningSpriteImage(const ParamData &param) const

Returns a sprite texture that is used for populating the specified data parameter.

This is only relevant for data parameters marked with the ShaderParamAttributeType::SpriteUV attribute.

GetSamplerState

void GetSamplerState(const ParamData &param, SPtr<SamplerState> &value) const

Equivalent to getSamplerState(const String & , SPtr <SamplerState > & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetSamplerState

void SetSamplerState(const ParamData &param, const SPtr<SamplerState> &value)

Equivalent to setSamplerState(const String & , const SPtr <SamplerState > & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetDefaultTexture

void GetDefaultTexture(const ParamData &param, TextureType &value) const

Returns the default texture (one assigned when no other is provided), if available for the specified parameter.

Parameter is represented using the internal parameter reference and the caller must guarantee the parameter eference is valid and belongs to this object.

GetDefaultSamplerState

void GetDefaultSamplerState(const ParamData &param, SPtr<SamplerState> &value) const

Returns the default sampler state (one assigned when no other is provided), if available for the specified parameter.

Parameter is represented using the internal parameter reference and the caller must guarantee the parameter reference is valid and belongs to this object.

Protected

Fields

mTextureParameters

TInlineArray<ParamTextureDataType, 8> mTextureParameters

mBufferParameters

TInlineArray<ParamBufferDataType, 4> mBufferParameters

mSamplerParameters

TInlineArray<ParamSamplerStateDataType, 2> mSamplerParameters

mDefaultTextureParams

TextureType * mDefaultTextureParams

mDefaultSamplerStateParams

SPtr<SamplerState> * mDefaultSamplerStateParams