Vulkan-specific material resource binder.
More...
#include <VulkanMaterial.h>
Inherits Raven::Material.
Vulkan-specific material resource binder.
VulkanMaterial extends Raven::Material and provides Vulkan-native handling of descriptors and shader resource bindings. It maintains maps of textures and uniform values which, when modified, mark the material as "dirty." On the next Bind() call, VulkanMaterial updates its descriptor set before binding it to the current command buffer.
Key Responsibilities:
- Manage lifetime of material-associated GPU resources (textures, samplers).
- Allocate and update descriptor sets from the renderer’s global descriptor pool.
- Provide overrides for setting material uniforms (float, vec3, vec4).
Usage:
- Construct with a reference to a Raven::Shader (VulkanShader backend required).
- Call SetTexture/SetFloat/etc. to configure material parameters.
- Call Bind(commandBuffer, pipelineLayout) to bind the material for rendering.
◆ VulkanMaterial()
| Raven::VulkanMaterial::VulkanMaterial |
( |
Ref< Shader > | shader | ) |
|
Constructs a VulkanMaterial using the provided shader.
Allocates a descriptor set from the global Vulkan descriptor pool using the layout defined in the shader (set = 2).
- Parameters
-
◆ Bind()
Binds this material's resources to the GPU pipeline.
If the material is marked dirty (modified since last bind), this updates the Vulkan descriptor set with all bound textures and the primary sampler. The descriptor set is then bound to the provided command buffer at set = 2.
- Parameters
-
| commandBuffer | Render command buffer used for issuing Vulkan commands. |
| pipelineLayout | Vulkan pipeline layout to bind against. |
Implements Raven::Material.
◆ Destroy()
| void Raven::VulkanMaterial::Destroy |
( |
| ) |
|
Releases all GPU-bound material resources.
This explicitly releases references to textures and the underlying shader. Should be called when the material is no longer needed.
◆ GetName()
| ILLUMINE_API const std::string & Raven::VulkanMaterial::GetName |
( |
| ) |
const |
|
inlineoverridevirtual |
Retrieves the name of this material.
- Returns
- The assigned material name.
Implements Raven::Material.
◆ SetFloat()
| void Raven::VulkanMaterial::SetFloat |
( |
const std::string & | name, |
|
|
float | value ) |
|
overridevirtual |
Assigns a scalar float value to the material.
- Parameters
-
| name | The shader uniform name. |
| value | The float value to bind. |
Implements Raven::Material.
◆ SetFloat3()
| void Raven::VulkanMaterial::SetFloat3 |
( |
const std::string & | name, |
|
|
const Crux::vec3 & | value ) |
|
overridevirtual |
Assigns a 3-component float vector to the material.
- Parameters
-
| name | The shader uniform name. |
| value | The vec3 value to bind. |
Implements Raven::Material.
◆ SetFloat4()
| void Raven::VulkanMaterial::SetFloat4 |
( |
const std::string & | name, |
|
|
const Crux::vec4 & | value ) |
|
overridevirtual |
Assigns a 4-component float vector to the material.
- Parameters
-
| name | The shader uniform name. |
| value | The vec4 value to bind. |
Implements Raven::Material.
◆ SetName()
| void Raven::VulkanMaterial::SetName |
( |
const std::string & | name | ) |
|
|
inlineoverridevirtual |
◆ SetTexture()
| void Raven::VulkanMaterial::SetTexture |
( |
const std::string & | name, |
|
|
Ref< Texture2D > | texture ) |
|
overridevirtual |
Assigns a 2D texture to the material.
- Parameters
-
| name | The shader resource name (e.g., "u_AlbedoMap"). |
| texture | Reference to a Texture2D resource. |
Implements Raven::Material.
The documentation for this class was generated from the following files: