docs: update resources API docs

This commit is contained in:
2026-03-20 02:35:35 +08:00
parent fd792b7df1
commit ea756c0177
314 changed files with 9439 additions and 1360 deletions

View File

@@ -0,0 +1,21 @@
# Material::ClearAllProperties
```cpp
void ClearAllProperties();
```
清空所有属性和纹理绑定。
**线程安全:**
**复杂度:** O(n)
**示例:**
```cpp
mat->ClearAllProperties();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetBool
```cpp
bool GetBool(const Containers::String& name) const;
```
获取布尔属性值。如果属性不存在则返回 false。
**参数:**
- `name` - 属性名称
**返回:** 布尔属性值,不存在则返回 false
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
bool receiveShadow = mat->GetBool("receiveShadow");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# Material::GetConstantBufferData
```cpp
const Containers::Array<Core::uint8>& GetConstantBufferData() const;
```
获取常量缓冲区原始数据。数据由 UpdateConstantBuffer() 更新。
**返回:** 常量缓冲区数据数组的引用
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->UpdateConstantBuffer();
const auto& cbData = mat->GetConstantBufferData();
// 将 cbData 上传到 GPU
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetFloat
```cpp
float GetFloat(const Containers::String& name) const;
```
获取浮点属性值。如果属性不存在则返回 0.0f。
**参数:**
- `name` - 属性名称
**返回:** 浮点属性值,不存在则返回 0.0f
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
float roughness = mat->GetFloat("roughness");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetFloat2
```cpp
Math::Vector2 GetFloat2(const Containers::String& name) const;
```
获取二维向量属性值。如果属性不存在则返回零向量。
**参数:**
- `name` - 属性名称
**返回:** 二维向量属性值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Math::Vector2 uvScale = mat->GetFloat2("uvScale");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetFloat3
```cpp
Math::Vector3 GetFloat3(const Containers::String& name) const;
```
获取三维向量属性值。如果属性不存在则返回零向量。
**参数:**
- `name` - 属性名称
**返回:** 三维向量属性值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Math::Vector3 albedo = mat->GetFloat3("albedo");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetFloat4
```cpp
Math::Vector4 GetFloat4(const Containers::String& name) const;
```
获取四维向量属性值。如果属性不存在则返回零向量。
**参数:**
- `name` - 属性名称
**返回:** 四维向量属性值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Math::Vector4 plane = mat->GetFloat4("planeEquation");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# Material::GetGUID
```cpp
ResourceGUID GetGUID() const override;
```
获取材质的全局唯一标识符。
**返回:** 资源 GUID
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
ResourceGUID guid = mat->GetGUID();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetInt
```cpp
Core::int32 GetInt(const Containers::String& name) const;
```
获取整数属性值。如果属性不存在则返回 0。
**参数:**
- `name` - 属性名称
**返回:** 整数属性值,不存在则返回 0
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
int32 normalScale = mat->GetInt("normalScale");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# Material::GetMemorySize
```cpp
size_t GetMemorySize() const override;
```
获取材质占用的内存大小。
**返回:** 内存大小(字节)
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
size_t memSize = mat->GetMemorySize();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# Material::GetName
```cpp
const Containers::String& GetName() const override;
```
获取材质的名称。
**返回:** 材质名称字符串的引用
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
const String& name = mat->GetName();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# Material::GetPath
```cpp
const Containers::String& GetPath() const override;
```
获取材质资源的路径。
**返回:** 资源路径字符串的引用
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
const String& path = mat->GetPath();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetShader
```cpp
class Shader* GetShader() const;
```
获取材质关联的着色器指针。
**返回:** 着色器指针,如果未设置则返回 nullptr
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Shader* shader = mat->GetShader();
if (shader != nullptr) {
// 使用着色器
}
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetTexture
```cpp
ResourceHandle<Texture> GetTexture(const Containers::String& name) const;
```
获取纹理属性句柄。
**参数:**
- `name` - 属性名称
**返回:** 纹理资源句柄
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Texture> albedoMap = mat->GetTexture("albedoMap");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::GetType
```cpp
ResourceType GetType() const override;
```
返回材质的资源类型,标识该资源为 Material 类型。
**返回:** `ResourceType::Material`
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
if (mat->GetType() == ResourceType::Material) {
// 这是一个材质资源
}
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,28 @@
# Material::HasProperty
```cpp
bool HasProperty(const Containers::String& name) const;
```
检查指定属性是否存在。
**参数:**
- `name` - 属性名称
**返回:** 属性存在返回 true否则返回 false
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
if (mat->HasProperty("roughness")) {
float roughness = mat->GetFloat("roughness");
}
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::IsValid
```cpp
bool IsValid() const override;
```
检查材质是否有效且已正确加载。
**返回:** 材质有效返回 true否则返回 false
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/pbr.mat");
if (mat->IsValid()) {
// 材质已成功加载
}
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -4,11 +4,13 @@
**类型**: `class`
**头文件**: `XCEngine/Resources/Material.h`
**描述**: 材质资源类,管理渲染所需的着色器和属性参数。
## 概述
`Material` 是 XCEngine 中的材质资源类,继承自 `IResource`。它管理材质关联的着色器和各种属性参数(浮点数、向量、纹理等),并支持将属性数据打包到常量缓冲区。
`Material` 是 XCEngine 中的材质资源类,继承自 `IResource`。它管理材质关联的着色器和各种属性参数(浮点数、向量、整数、布尔值、纹理等),并支持将属性数据打包到常量缓冲区供 GPU 着色器使用
## 头文件
@@ -20,7 +22,7 @@
### MaterialPropertyType
材质属性类型枚举。
材质属性类型枚举,定义材质支持的属性数据类型
| 值 | 描述 |
|----|------|
@@ -28,124 +30,135 @@
| `Float2` | 二维浮点向量 |
| `Float3` | 三维浮点向量 |
| `Float4` | 四维浮点向量 |
| `Int` | 整数 |
| `Int` | 32位整数 |
| `Int2` | 二维整数向量 |
| `Int3` | 三维整数向量 |
| `Int4` | 四维整数向量 |
| `Bool` | 布尔值 |
| `Texture` | 纹理资源 |
| `Texture` | 二维纹理资源 |
| `Cubemap` | 立方体贴图资源 |
## 结构体
### MaterialProperty
材质属性结构体。
材质属性结构体,存储单个属性的名称、类型和值
| 成员 | 类型 | 描述 |
|------|------|------|
| `name` | `Containers::String` | 属性名称 |
| `type` | `MaterialPropertyType` | 属性类型 |
| `value` | `union` | 属性值float/int/bool |
| `name` | `Containers::String` | 属性名称标识符 |
| `type` | `MaterialPropertyType` | 属性数据类型 |
| `value` | `union Value` | 属性值联合体,支持 float[4]、int[4]、bool |
| `refCount` | `Core::uint32` | 引用计数 |
## 公共方法
## 公共方法表格
### 基础属性
### 资源基类方法
| 方法 | 描述 |
|------|------|
| `ResourceType GetType() const` | 返回 `ResourceType::Material` |
| `const Containers::String& GetName() const` | 获取材质名称 |
| `const Containers::String& GetPath() const` | 获取材质路径 |
| `ResourceGUID GetGUID() const` | 获取全局唯一标识符 |
| `bool IsValid() const` | 检查材质是否有效 |
| `size_t GetMemorySize() const` | 获取内存大小 |
| `void Release()` | 释放材质引用 |
| `GetType()` | 返回 `ResourceType::Material` |
| `GetName()` | 获取材质名称 |
| `GetPath()` | 获取材质资源路径 |
| `GetGUID()` | 获取全局唯一标识符 |
| `IsValid()` | 检查材质是否有效且已加载 |
| `GetMemorySize()` | 获取材质占用的内存大小 |
| `Release()` | 释放材质所有引用和资源 |
### 着色器管理
| 方法 | 描述 |
|------|------|
| `void SetShader(const ResourceHandle<Shader>& shader)` | 设置材质着色器 |
| `Shader* GetShader() const` | 获取材质着色器 |
| [`SetShader`](set-shader.md) | 设置材质使用的着色器 |
| [`GetShader`](get-shader.md) | 获取材质关联的着色器指针 |
### 属性设置
### 属性设置方法
| 方法 | 描述 |
|------|------|
| `void SetFloat(const Containers::String& name, float value)` | 设置浮点属性 |
| `void SetFloat2(const Containers::String& name, const Math::Vector2& value)` | 设置 Vector2 属性 |
| `void SetFloat3(const Containers::String& name, const Math::Vector3& value)` | 设置 Vector3 属性 |
| `void SetFloat4(const Containers::String& name, const Math::Vector4& value)` | 设置 Vector4 属性 |
| `void SetInt(const Containers::String& name, Core::int32 value)` | 设置整数属性 |
| `void SetBool(const Containers::String& name, bool value)` | 设置布尔属性 |
| `void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture)` | 设置纹理属性 |
| [`SetFloat`](set-float.md) | 设置浮点属性 |
| [`SetFloat2`](set-float2.md) | 设置二维向量属性 |
| [`SetFloat3`](set-float3.md) | 设置三维向量属性 |
| [`SetFloat4`](set-float4.md) | 设置四维向量属性 |
| [`SetInt`](set-int.md) | 设置整数属性 |
| [`SetBool`](set-bool.md) | 设置布尔属性 |
| [`SetTexture`](set-texture.md) | 设置纹理属性 |
### 属性获取
### 属性获取方法
| 方法 | 描述 |
|------|------|
| `float GetFloat(const Containers::String& name) const` | 获取浮点属性 |
| `Math::Vector2 GetFloat2(const Containers::String& name) const` | 获取 Vector2 属性 |
| `Math::Vector3 GetFloat3(const Containers::String& name) const` | 获取 Vector3 属性 |
| `Math::Vector4 GetFloat4(const Containers::String& name) const` | 获取 Vector4 属性 |
| `Core::int32 GetInt(const Containers::String& name) const` | 获取整数属性 |
| `bool GetBool(const Containers::String& name) const` | 获取布尔属性 |
| `ResourceHandle<Texture> GetTexture(const Containers::String& name) const` | 获取纹理属性 |
| [`GetFloat`](get-float.md) | 获取浮点属性值,不存在返回 0.0f |
| [`GetFloat2`](get-float2.md) | 获取二维向量属性 |
| [`GetFloat3`](get-float3.md) | 获取三维向量属性 |
| [`GetFloat4`](get-float4.md) | 获取四维向量属性 |
| [`GetInt`](get-int.md) | 获取整数属性值,不存在返回 0 |
| [`GetBool`](get-bool.md) | 获取布尔属性值,不存在返回 false |
| [`GetTexture`](get-texture.md) | 获取纹理属性句柄 |
### 常量缓冲区
| 方法 | 描述 |
|------|------|
| `const Containers::Array<Core::uint8>& GetConstantBufferData() const` | 获取常量缓冲区数据 |
| `void UpdateConstantBuffer()` | 更新常量缓冲区数据 |
| [`GetConstantBufferData`](get-constant-buffer-data.md) | 获取常量缓冲区原始数据 |
| [`UpdateConstantBuffer`](update-constant-buffer.md) | 更新常量缓冲区数据 |
### 属性管理
### 属性查询与管理
| 方法 | 描述 |
|------|------|
| `bool HasProperty(const Containers::String& name) const` | 检查属性是否存在 |
| `void RemoveProperty(const Containers::String& name)` | 移除属性 |
| `void ClearAllProperties()` | 清空所有属性 |
## 实现说明
**注意**: `MaterialLoader::ParseMaterialData()` 为 stub始终返回 true。`MaterialLoader::Load()` 仅为示例实现,未解析材质属性。
| [`HasProperty`](has-property.md) | 检查指定属性是否存在 |
| [`RemoveProperty`](remove-property.md) | 移除指定属性 |
| [`ClearAllProperties`](clear-all-properties.md) | 清空所有属性和纹理绑定 |
## 使用示例
```cpp
// 加载材质
// 通过资源管理器加载材质
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/player.mat");
// 设置着色器
mat->SetShader(shaderHandle);
ResourceHandle<Shader> shader = ResourceManager::Get().Load<Shader>("shaders/pbr.shader");
mat->SetShader(shader);
// 设置各种属性
// 设置材质属性
mat->SetFloat("roughness", 0.5f);
mat->SetFloat("metallic", 0.0f);
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->SetFloat4("emission", Math::Vector4(1.0f, 0.5f, 0.2f, 2.0f));
mat->SetInt("normalScale", 1);
mat->SetBool("receiveShadow", true);
// 设置纹理
ResourceHandle<Texture> albedoTex = ResourceManager::Get().Load<Texture>("textures/albedo.png");
ResourceHandle<Texture> normalTex = ResourceManager::Get().Load<Texture>("textures/normal.png");
ResourceHandle<Texture> roughnessTex = ResourceManager::Get().Load<Texture>("textures/roughness.png");
mat->SetTexture("albedoMap", albedoTex);
mat->SetTexture("normalMap", normalTex);
mat->SetInt("normalScale", 1);
mat->SetTexture("roughnessMap", roughnessTex);
// 获取属性
float roughness = mat->GetFloat("roughness");
Math::Vector3 albedo = mat->GetFloat3("albedo");
Shader* shader = mat->GetShader();
// 检查属性
// 属性查询
if (mat->HasProperty("metallic")) {
float metallic = mat->GetFloat("metallic");
}
// 更新常量缓冲区
// 更新常量缓冲区供 GPU 使用
mat->UpdateConstantBuffer();
auto cbData = mat->GetConstantBufferData();
const auto& cbData = mat->GetConstantBufferData();
// 释放材质
mat->Release();
```
## 相关文档
- [IResource](../iresource/iresource.md) - 资源基类
- [IResource](../iresource/iresource.md) - 资源基类接口
- [Shader](../shader/shader.md) - 着色器资源
- [Texture](../texture/texture.md) - 纹理资源
- [Resources 总览](../resources.md) - 返回模块总览
- [ResourceHandle](../resourcehandle/resourcehandle.md) - 资源句柄
- [Resources 模块总览](../resources.md) - 返回模块总览

View File

@@ -0,0 +1,26 @@
# Material::Release
**方法签名**:
```cpp
void Release() override
```
**详细描述**: 释放材质的所有引用和资源。调用后着色器引用、属性映射、纹理绑定和常量缓冲区数据都将被清空,材质变为无效状态。
**参数**: 无
**返回值**: 无
**复杂度**: O(n)n 为属性和纹理绑定数量
**示例**:
```cpp
mat->Release();
// 调用后 mat->IsValid() 返回 false
```
## 相关文档
- [Material 总览](material.md) - 返回类总览
- [IResource::Release](../iresource/iresource.md) - 资源基类接口

View File

@@ -0,0 +1,24 @@
# Material::RemoveProperty
```cpp
void RemoveProperty(const Containers::String& name);
```
移除指定属性。
**参数:**
- `name` - 属性名称
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->RemoveProperty("roughness");
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::SetBool
```cpp
void SetBool(const Containers::String& name, bool value);
```
设置布尔属性值。
**参数:**
- `name` - 属性名称
- `value` - 布尔值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetBool("receiveShadow", true);
mat->SetBool("castShadow", false);
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::SetFloat
```cpp
void SetFloat(const Containers::String& name, float value);
```
设置浮点属性值。如果属性不存在则创建,存在则更新。
**参数:**
- `name` - 属性名称
- `value` - 浮点数值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat("metallic", 0.8f);
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# Material::SetFloat2
```cpp
void SetFloat2(const Containers::String& name, const Math::Vector2& value);
```
设置二维向量属性值。
**参数:**
- `name` - 属性名称
- `value` - 二维向量值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat2("uvScale", Math::Vector2(2.0f, 2.0f));
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::SetFloat3
```cpp
void SetFloat3(const Containers::String& name, const Math::Vector3& value);
```
设置三维向量属性值,常用于颜色、法线缩放等。
**参数:**
- `name` - 属性名称
- `value` - 三维向量值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->SetFloat3("emission", Math::Vector3(0.5f, 0.5f, 0.5f));
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# Material::SetFloat4
```cpp
void SetFloat4(const Containers::String& name, const Math::Vector4& value);
```
设置四维向量属性值。
**参数:**
- `name` - 属性名称
- `value` - 四维向量值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat4("planeEquation", Math::Vector4(0.0f, 1.0f, 0.0f, 0.0f));
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::SetInt
```cpp
void SetInt(const Containers::String& name, Core::int32 value);
```
设置整数属性值。
**参数:**
- `name` - 属性名称
- `value` - 整数值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetInt("normalScale", 1);
mat->SetInt("uSampleCount", 4);
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# Material::SetShader
```cpp
void SetShader(const ResourceHandle<class Shader>& shader);
```
设置材质使用的着色器。
**参数:**
- `shader` - 着色器资源句柄
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Shader> shader = ResourceManager::Get().Load<Shader>("shaders/pbr.shader");
mat->SetShader(shader);
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -1,16 +1,16 @@
# Material::SetTexture
```cpp
void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture)
void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture);
```
设置材质纹理属性。
设置纹理属性。
**参数:**
- `name` - 属性名称
- `texture` - 纹理资源句柄
**返回**
**线程安全**
**复杂度:** O(1)
@@ -25,4 +25,4 @@ mat->SetTexture("normalMap", normalTex);
## 相关文档
- [Material 总览](material.md) - 返回类总览
- [Material](material.md) - 返回类总览

View File

@@ -1,27 +0,0 @@
# Material::SetFloat
```cpp
void SetFloat(const Containers::String& name, float value)
```
设置材质浮点属性。
**参数:**
- `name` - 属性名称
- `value` - 属性值
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat("metallic", 0.0f);
mat->SetFloat("emissionStrength", 2.0f);
```
## 相关文档
- [Material 总览](material.md) - 返回类总览

View File

@@ -1,26 +0,0 @@
# Material::SetShader
```cpp
void SetShader(const ResourceHandle<Shader>& shader)
```
设置材质使用的着色器。
**参数:**
- `shader` - 着色器资源句柄
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Shader> vs = ResourceManager::Get().Load<Shader>("shaders/vertex.glsl");
ResourceHandle<Shader> fs = ResourceManager::Get().Load<Shader>("shaders/fragment.glsl");
mat->SetShader(vs);
```
## 相关文档
- [Material 总览](material.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# Material::UpdateConstantBuffer
```cpp
void UpdateConstantBuffer();
```
更新常量缓冲区数据。清空当前常量缓冲区数据。
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->UpdateConstantBuffer();
```
## 相关文档
- [Material](material.md) - 返回类总览

View File

@@ -1,26 +0,0 @@
# Material::UpdateConstantBuffer
```cpp
void UpdateConstantBuffer()
```
更新材质常量缓冲区。将所有属性值打包到常量缓冲区的二进制数据中,供 GPU 着色器使用。
**参数:**
**返回:**
**复杂度:** O(n)n 为属性数量
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->UpdateConstantBuffer();
auto cbData = mat->GetConstantBufferData();
```
## 相关文档
- [Material 总览](material.md) - 返回类总览