Berserk
|
Controls how object is actually rendered. More...
#include <Material.hpp>
Public Member Functions | |
BRK_API | Material (Ref< const Shader > shader) |
Creates new material instance from provided shader. More... | |
BRK_API | ~Material () override=default |
BRK_API void | SetName (StringName name) |
BRK_API void | SetDescription (String description) |
BRK_API void | SetTexture (const StringName &name, Ref< RHITexture > texture, Ref< RHISampler > sampler, uint32 arrayIndex=0) |
Set material texture parameter. More... | |
BRK_API void | SetFloat1 (const StringName &name, float value, uint32 arrayIndex=0) |
Set material float parameter. More... | |
BRK_API void | SetFloat2 (const StringName &name, const Vec2f &value, uint32 arrayIndex=0) |
Set material float vec2 parameter. More... | |
BRK_API void | SetFloat3 (const StringName &name, const Vec3f &value, uint32 arrayIndex=0) |
Set material float vec3 parameter. More... | |
BRK_API void | SetFloat4 (const StringName &name, const Vec4f &value, uint32 arrayIndex=0) |
Set material float vec4 parameter. More... | |
BRK_API void | SetInt1 (const StringName &name, int32 value, uint32 arrayIndex=0) |
Set material int parameter. More... | |
BRK_API void | SetInt2 (const StringName &name, const Vec2i &value, uint32 arrayIndex=0) |
Set material int vec2 parameter. More... | |
BRK_API void | SetInt3 (const StringName &name, const Vec3i &value, uint32 arrayIndex=0) |
Set material int vec3 parameter. More... | |
BRK_API void | SetInt4 (const StringName &name, const Vec4i &value, uint32 arrayIndex=0) |
Set material int vec4 parameter. More... | |
BRK_API void | SetUInt1 (const StringName &name, uint32 value, uint32 arrayIndex=0) |
Set material uint parameter. More... | |
BRK_API void | SetUInt2 (const StringName &name, const Vec2u &value, uint32 arrayIndex=0) |
Set material uint vec2 parameter. More... | |
BRK_API void | SetUInt3 (const StringName &name, const Vec3u &value, uint32 arrayIndex=0) |
Set material uint vec3 parameter. More... | |
BRK_API void | SetUInt4 (const StringName &name, const Vec4u &value, uint32 arrayIndex=0) |
Set material uint vec4 parameter. More... | |
BRK_API void | SetBool1 (const StringName &name, bool value, uint32 arrayIndex=0) |
Set material bool parameter. More... | |
BRK_API void | SetBool2 (const StringName &name, const Vec2b &value, uint32 arrayIndex=0) |
Set material bool vec2 parameter. More... | |
BRK_API void | SetBool3 (const StringName &name, const Vec3b &value, uint32 arrayIndex=0) |
Set material bool vec3 parameter. More... | |
BRK_API void | SetBool4 (const StringName &name, const Vec4b &value, uint32 arrayIndex=0) |
Set material bool vec4 parameter. More... | |
BRK_API void | SetMat2 (const StringName &name, const Mat2x2f &value, uint32 arrayIndex=0) |
Set material float mat2x2 parameter. More... | |
BRK_API void | SetMat3 (const StringName &name, const Mat3x3f &value, uint32 arrayIndex=0) |
Set material float mat3x3 parameter. More... | |
BRK_API void | SetMat4 (const StringName &name, const Mat4x4f &value, uint32 arrayIndex=0) |
Set material float mat4x4 parameter. More... | |
BRK_API void | UpdatePack () |
Update rhi-set of the material. More... | |
BRK_API bool | IsDirty () const |
BRK_API const StringName & | GetName () const |
BRK_API const String & | GetDescription () const |
BRK_API const Ref< const Shader > & | GetShader () const |
BRK_API const Ref< const ShaderTechnique > & | GetTechnique () const |
BRK_API const ShaderVariation & | GetVariation () const |
BRK_API Ref< const MaterialParams > | GetPackedParams () const |
![]() | |
virtual | ~RefCnt () |
bool | IsUnique () const |
std::int32_t | GetRefs () const |
std::int32_t | AddRef () const |
std::int32_t | RelRef () const |
Friends | |
class | MaterialParams |
Additional Inherited Members | |
![]() | |
virtual void | Destroy () const |
Controls how object is actually rendered.
Material is composed of the shader object and a set of material params. Shader object defines the set of available params for rendering settings and provides a set of techniques, which define a gpu passes used to actually draw an object. Material params provide user the ability to easily set params to tweak rendering of the concrete object.
|
explicit |
Creates new material instance from provided shader.
Provided shader must be valid, loaded and compiled shader object with fully set state. Material will select the best available technique from this shader and set its as technique for rendering.
shader | Valid shader object |
|
overridedefault |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void Material::SetBool1 | ( | const StringName & | name, |
bool | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material bool parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetBool2 | ( | const StringName & | name, |
const Vec2b & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material bool vec2 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetBool3 | ( | const StringName & | name, |
const Vec3b & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material bool vec3 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetBool4 | ( | const StringName & | name, |
const Vec4b & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material bool vec4 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetDescription | ( | String | description | ) |
Set optional material description
void Material::SetFloat1 | ( | const StringName & | name, |
float | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetFloat2 | ( | const StringName & | name, |
const Vec2f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float vec2 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetFloat3 | ( | const StringName & | name, |
const Vec3f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float vec3 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetFloat4 | ( | const StringName & | name, |
const Vec4f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float vec4 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetInt1 | ( | const StringName & | name, |
int32 | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material int parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetInt2 | ( | const StringName & | name, |
const Vec2i & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material int vec2 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetInt3 | ( | const StringName & | name, |
const Vec3i & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material int vec3 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetInt4 | ( | const StringName & | name, |
const Vec4i & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material int vec4 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetMat2 | ( | const StringName & | name, |
const Mat2x2f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float mat2x2 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetMat3 | ( | const StringName & | name, |
const Mat3x3f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float mat3x3 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetMat4 | ( | const StringName & | name, |
const Mat4x4f & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material float mat4x4 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetName | ( | StringName | name | ) |
Set material name
void Material::SetTexture | ( | const StringName & | name, |
Ref< RHITexture > | texture, | ||
Ref< RHISampler > | sampler, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material texture parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
texture | Texture object to set |
sampler | Sampler object to set |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetUInt1 | ( | const StringName & | name, |
uint32 | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material uint parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetUInt2 | ( | const StringName & | name, |
const Vec2u & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material uint vec2 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetUInt3 | ( | const StringName & | name, |
const Vec3u & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material uint vec3 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::SetUInt4 | ( | const StringName & | name, |
const Vec4u & | value, | ||
uint32 | arrayIndex = 0 |
||
) |
Set material uint vec4 parameter.
Updates material parameter value. Makes material in dirty state, so requires actual rhi parameters repacking.
name | Parameter name |
value | Parameter value |
arrayIndex | Optional array index to modify; for not array params by default is 0 |
void Material::UpdatePack | ( | ) |
Update rhi-set of the material.
Must be called by the material owner before rendering to update actual state of material params and data on GPU-side.
|
friend |