class ShaderVariationParameters

Contains information about a single variation of a Shader.

Each variation can have a separate set of

defines that control shader compilation.

Public

Constructors

ShaderVariationParameters

ShaderVariationParameters() = default

ShaderVariationParameters

ShaderVariationParameters(const TInlineArray<ShaderVariationParameter, 4> &params)

Creates a new shader variation with the specified parameters.

Methods

GetI32

i32 GetI32(const StringID &name)

Returns the value of a signed integer parameter with the specified name.

Returns 0 if the parameter cannot be found.

GetUI32

u32 GetUI32(const StringID &name)

Returns the value of a unsigned integer parameter with the specified name.

Returns 0 if the parameter cannot be found.

GetFloat

float GetFloat(const StringID &name)

Returns the value of a float parameter with the specified name.

Returns 0 if the parameter cannot be found.

GetBool

bool GetBool(const StringID &name)

Returns the value of a boolean parameter with the specified name.

Returns false if the parameter cannot be found.

SetI32

void SetI32(const StringID &name, i32 value)

Sets the value of the parameter for the provided name.

Any previous value for a parameter with the same name will be overwritten.

SetU32

void SetU32(const StringID &name, u32 value)

Sets the value of the parameter for the provided name.

Any previous value for a parameter with the same name will be overwritten.

SetFloat

void SetFloat(const StringID &name, float value)

Sets the value of the parameter for the provided name.

Any previous value for a parameter with the same name will be overwritten.

SetBool

void SetBool(const StringID &name, bool value)

Sets the value of the parameter for the provided name.

Any previous value for a parameter with the same name will be overwritten.

AddParameter

void AddParameter(const ShaderVariationParameter &parameter)

Registers a new parameter that controls the variation.

RemoveParameter

void RemoveParameter(const StringID &parameter)

Removes a parameter with the specified name.

HasParameter

bool HasParameter(const StringID &paramName)

Checks if the variation has a parameter with the specified name.

ClearParameters

void ClearParameters()

Removes all parameters.

FindParameter

const ShaderVariationParameter *FindParameter(const StringID &name) const

Attempts to find a parameter with the provided name, or returns null if not found.

GetParameters

Vector<String> GetParameters() const

Returns a list of names of all registered parameters.

CreateVariationName

String CreateVariationName() const

Creates a unique name created from all parameters and their values.

Matches

bool Matches(const ShaderVariationParameters &other, bool exact = true) const

Checks if this variation matches some other variation.

other
Other variation to compare it to.
exact
When true both variations need to have the exact number of parameters with identical contents, equivalent to the equals operator. When false, only the subset of parameters present in is used for comparison, while any extra parameters present in this object are ignored.

GetParameterList

const TInlineArray<ShaderVariationParameter, 4> &GetParameterList() const

Returns all the variation parameters.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Operators

operator==

bool operator==(const ShaderVariationParameters &rhs) const

operator!=

bool operator!=(const ShaderVariationParameters &rhs) const

Internal

Methods

GetDefines

ShaderDefines GetDefines() const

Converts all the variation parameters in a ShaderDefines object, that may be consumed by the shader compiler.

GetIndex

u32 GetIndex() const

Returns a unique index of this variation, relative to all other variations registered in ShaderVariations object.

SetIndex

void SetIndex(u32 idx) const

Assigns a unique index to the variation that can later be used for quick lookup.

Private

Methods

FindParameter

ShaderVariationParameter *FindParameter(const StringID &name)

Non-const overload of FindParameter() const.

Fields

mParams

TInlineArray<ShaderVariationParameter, 4> mParams

mIndex

u32 mIndex