Class Material

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class Material : public portal::Resource

Abstract material interface for shader parameter binding.

Binds shader parameters (uniforms, textures, images) by name using reflection. Supports scalars, vectors, matrices, textures, and images.

Subclassed by portal::renderer::vulkan::VulkanMaterial

Public Functions

inline explicit Material(const StringId &id)
template<typename T>
inline void set(const StringId bind_point, const T &t)

Binds scalar uniform (int, float, etc.)

Template Parameters:

T – Scalar type

Parameters:
  • bind_point – Uniform name

  • t – Value to bind

template<reflection::IsVec T>
inline void set(const StringId bind_point, const T &t)

Binds vector uniform (vec2, vec3, vec4)

Template Parameters:

T – Vector type

Parameters:
  • bind_point – Uniform name

  • t – Value to bind

template<reflection::IsMatrix T>
inline void set(const StringId bind_point, const T &t)

Binds matrix uniform (mat2, mat3, mat4)

Template Parameters:

T – Matrix type

Parameters:
  • bind_point – Uniform name

  • t – Value to bind

virtual void set(StringId bind_point, const ResourceReference<Texture> &texture) = 0

Binds texture (resource reference)

virtual void set(StringId bind_point, const Reference<Texture> &texture) = 0

Binds texture.

virtual void set(StringId bind_point, const Reference<Image> &image) = 0

Binds image.

virtual void set(StringId bind_point, const Reference<ImageView> &image) = 0

Binds image view.

template<typename T>
inline T &get(const StringId bind_point)

Gets scalar uniform value.

Template Parameters:

T – Scalar type

Parameters:

bind_point – Uniform name

Returns:

Reference to uniform value

template<reflection::IsVec T>
inline T &get(const StringId bind_point)

Gets vector uniform value.

Template Parameters:

T – Vector type

Parameters:

bind_point – Uniform name

Returns:

Reference to uniform value

template<reflection::IsMatrix T>
inline T &get(const StringId bind_point)

Gets matrix uniform value.

Template Parameters:

T – Matrix type

Parameters:

bind_point – Uniform name

Returns:

Reference to uniform value

virtual Reference<Texture> get_texture(const StringId bind_point) = 0

Gets bound texture.

Parameters:

bind_pointTexture binding name

Returns:

Texture reference

virtual Reference<Image> get_image(const StringId bind_point) = 0

Gets bound image.

Parameters:

bind_pointImage binding name

Returns:

Image reference

virtual Reference<ImageView> get_image_view(const StringId bind_point) = 0

Gets bound image view.

Parameters:

bind_pointImage view binding name

Returns:

Image view reference

virtual Reference<ShaderVariant> get_shader() = 0

Gets material shader.

Public Static Functions

static inline portal::ResourceType static_type()

Protected Functions

virtual void set_property(StringId bind_point, const reflection::Property &property) = 0

Sets property by reflection.

Parameters:
  • bind_point – Property name

  • property – Property data

virtual bool get_property(StringId bind_point, reflection::Property &property) const = 0

Gets property by reflection.

Parameters:
  • bind_point – Property name

  • property – Output property data

Returns:

True if property found