V6.0.0.300版本开始,该类已融合到MaterialInstance类,您无需额外调用Material,即可实现材质属性信息的定义。
Class Info |
|---|
class Material : public IResource 材质类,负责管线初始化,着色器的绑定,纹理、光栅化状态、深度测试、混合操作的设置和获取。 |
Qualifier and Type |
Method Name and Description |
|---|---|
void |
Init() 初始化管线状态。 |
void |
SetSubMesh(const SubMesh* subMesh) 根据指定子网格设置管线状态绑定的顶点声明、顶点缓冲区和索引缓冲区。 |
void |
AttachShaderStage(ShaderStageType stage, const String& filePath) 管线绑定指定类型着色器。 |
void |
SetTexture(TextureType type, const String& filePath) 设置纹理。 |
void |
SetSamplerParam(TextureType type, SamplerFilter filterMin, SamplerFilter filterMag, SamplerMipmapMode filterMipmap, SamplerAddress addressMode) 设置采样参数。 |
bool |
HasTexture(const TextureType type) const 判断是否存在指定类型纹理。 |
const RenderPipeline* |
GetRenderPipeline() const 获取绑定的渲染管线指针。 |
const String& |
GetTexturePathByType(TextureType type) const 获取指定类型纹理的路径。 |
| 获取所有纹理路径。 |
|
const Texture* |
GetTexture(TextureType type) const 获取指定类型纹理。 |
GetTextureSet(TextureType type) const 获取指定类型纹理集合序号。 |
|
GetTextureBinding(TextureType type) const 获取指定类型纹理的绑定索引。 |
|
void |
SetCullMode(CullMode cullMode) 设置管线中光栅化阶段的剔除模式参数。 |
GetCullMode() const 获取管线中光栅化阶段的剔除模式参数。 |
|
void |
SetFillMode(FillMode fillMode) 设置管线中光栅化阶段的图元填充模式。 |
GetFillMode() const 获取管线中光栅化阶段的图元填充模式。 |
|
void |
SetFrontFace(FrontFace frontFace) 设置管线中光栅化阶段的三角形顶点绕序。 |
GetFrontFace() const 获取管线中光栅化阶段的三角形顶点绕序,顺时针或逆时针。 |
|
void |
SetDepthTestEnable(bool depthTestEnable) 设置深度测试使能标志变量。 |
bool |
GetDepthTestEnable() const 获取深度测试使能标志变量。 |
void |
SetDepthWriteEnable(bool depthWriteEnable) 设置深度测试写入使能标志变量。 |
bool |
GetDepthWriteEnable() const 获取深度测试写入使能标志变量。 |
void |
SetDepthCompareOp(CompareOperation op) 设置深度测试比较方式。 |
GetDepthCompareOp() const 获取深度测试比较方式。 |
|
void |
SetBlendingEnable(u32 index, bool bEnable) 设置每个颜色附件的混合状态使能标志变量。 |
bool |
GetBlendingEnable(u32 index) const 获取指定颜色附件的混合状态使能标志变量。 |
void |
SetSrcColorBlend(u32 index, BlendFactor srcColorBlend) 设置指定颜色附件的源颜色通道混合系数。 |
GetSrcColorBlend(u32 index) const 获取指定颜色附件的源颜色通道混合系数。 |
|
void |
SetDstColorBlend(u32 index, BlendFactor dstColorBlend) 设置指定颜色附件的目标颜色通道混合系数。 |
GetDstColorBlend(u32 index) const 获取指定颜色附件的目标颜色通道混合系数。 |
|
void |
SetColorBlendOperation(u32 index, BlendOperation colorBlendOp) 设置指定颜色附件的颜色混合操作。 |
GetColorBlendOperation(u32 index) const 获取指定颜色附件的颜色混合操作。 |
|
void |
SetSrcAlphaBlend(u32 index, BlendFactor srcAlphaBlend) 设置指定颜色附件的源Alpha通道系数。 |
GetSrcAlphaBlend(u32 index) const 获取指定颜色附件的源Alpha通道系数。 |
|
void |
SetDstAlphaBlend(u32 index, BlendFactor dstAlphaBlend) 设置指定颜色附件的目标Alpha通道系数。 |
GetDstAlphaBlend(u32 index) const 获取指定颜色附件的目标Alpha通道系数。 |
|
void |
SetAlphaBlendOperation(u32 index, BlendOperation alphaBlendOp) 设置指定颜色附件的Alpha通道混合操作。 |
GetAlphaBlendOperation(u32 index) const 获取指定颜色附件的Alpha通道混合操作。 |
|
void |
Create() 配置管线状态,包括着色器、视口、裁剪状态,并创建渲染管线。 |
virtual bool |
Resume() override 应用程序从后台切到前台时,完成材质资源的重建。 |
virtual void |
Pause() override 应用程序从前台切到后台时,完成材质资源的销毁。 |
Constructor |
|---|
Material(const String& filePath) 构造函数。 |
Parameters
Name |
Description |
|---|---|
filePath |
材质资源文件的路径。 |
Method |
|---|
void SetSubMesh(const SubMesh* subMesh) 根据指定子网格设置管线状态绑定的顶点声明、顶点缓冲区和索引缓冲区。 |
Parameters
Name |
Description |
|---|---|
subMesh |
指向子网格的指针,提供绑定的顶点声明、顶点缓冲区、索引缓冲区等信息。 |
Method |
|---|
void AttachShaderStage(ShaderStageType stage, const String& filePath) 管线绑定指定类型着色器。 |
Parameters
Name |
Description |
|---|---|
stage |
ShaderStageType类型,如顶点着色阶段、片段着色阶段等。 |
filePath |
字符串类型着色器文件路径。 |
Method |
|---|
void SetTexture(TextureType type, const String& filePath) 设置纹理。 |
Parameters
Name |
Description |
|---|---|
type |
TextureType类型纹理类型。 |
filePath |
字符串类型纹理路径。 |
Method |
|---|
void SetSamplerParam( TextureType type, SamplerFilter filterMin, SamplerFilter filterMag, SamplerMipmapMode filterMipmap, SamplerAddress addressMode) 设置采样参数。 |
Parameters
Name |
Description |
|---|---|
type |
纹理类型。参见TextureType。 |
filterMin |
纹理最小采样过滤器。参见SamplerFilter。 |
filterMag |
纹理最大采样过滤器。参见SamplerFilter。 |
filterMipmap |
MIPMAP采样模式。参见SamplerMipmapMode。 |
addressMode |
纹理寻址模式。参见SamplerAddress。 |
Method |
|---|
bool HasTexture(const TextureType type) const 判断是否存在指定类型纹理。 |
Parameters
Name |
Description |
|---|---|
type |
指定的纹理类型。参见TextureType。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
const RenderPipeline* GetRenderPipeline() const 获取绑定的渲染管线指针。 |
Returns
Type |
Description |
|---|---|
const RenderPipeline* |
指向绑定的渲染管线的指针。 |
Method |
|---|
const String& GetTexturePathByType(TextureType type) const 获取指定类型纹理的路径。 |
Parameters
Name |
Description |
|---|---|
type |
指定纹理类型。参见TextureType。 |
Returns
Type |
Description |
|---|---|
const String& |
字符串类型纹理路径。 |
Method |
|---|
StringVector GetTexturePaths() 获取所有纹理路径。 |
Returns
Type |
Description |
|---|---|
返回所有纹理路径。 |
Method |
|---|
const Texture* GetTexture(TextureType type) const 获取指定类型纹理。 |
Parameters
Name |
Description |
|---|---|
type |
指定的纹理类型。参见TextureType。 |
Returns
Type |
Description |
|---|---|
const Texture* |
返回指定类型纹理。 |
Method |
|---|
u32 GetTextureSet(TextureType type) const 获取指定类型纹理集合序号。 |
Parameters
Name |
Description |
|---|---|
type |
指定的纹理类型。参见TextureType。 |
Returns
Type |
Description |
|---|---|
指定类型纹理集合序号。 |
Method |
|---|
u32 GetTextureBinding(TextureType type) const 获取指定类型纹理的绑定索引。 |
Parameters
Name |
Description |
|---|---|
type |
指定的纹理类型。参见TextureType。 |
Returns
Type |
Description |
|---|---|
指定类型纹理绑定索引。 |
Method |
|---|
void SetCullMode(CullMode cullMode) 设置管线中光栅化阶段的剔除模式参数。 |
Parameters
Name |
Description |
|---|---|
cullMode |
CullMode类型剔除模式枚举值。 |
Method |
|---|
CullMode GetCullMode() const 获取管线中光栅化阶段的剔除模式参数。 |
Returns
Type |
Description |
|---|---|
返回管线中光栅化阶段的剔除模式参数。 |
Method |
|---|
void SetFillMode(FillMode fillMode) 设置管线中光栅化阶段的图元填充模式。 |
Parameters
Name |
Description |
|---|---|
fillMode |
填充模式枚举值,如点、线段、全填充。 |
Method |
|---|
void SetFrontFace(FrontFace frontFace) 设置管线中光栅化阶段的三角形顶点绕序。 |
Parameters
Name |
Description |
|---|---|
frontFace |
FrontFace枚举值,顺时针或逆时针。 |
Method |
|---|
void SetDepthTestEnable(bool depthTestEnable) 设置深度测试使能标志变量。 |
Parameters
Name |
Description |
|---|---|
depthTestEnable |
深度测试使能标志变量。 |
Method |
|---|
bool GetDepthTestEnable() const 获取深度测试使能标志变量。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetDepthWriteEnable(bool depthWriteEnable) 设置深度测试写入使能标志变量。 |
Parameters
Name |
Description |
|---|---|
depthWriteEnable |
深度测试写入使能标志变量。 |
Method |
|---|
bool GetDepthWriteEnable() const 获取深度测试写入使能标志变量。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetDepthCompareOp(CompareOperation op) 设置深度测试比较方式。 |
Parameters
Name |
Description |
|---|---|
op |
CompareOperation类型深度测试比较方式枚举值。 |
Method |
|---|
CompareOperation GetDepthCompareOp() const 获取深度测试比较方式。 |
Returns
Type |
Description |
|---|---|
深度测试比较方式枚举值。 |
Method |
|---|
void SetBlendingEnable(u32 index, bool bEnable) 设置每个颜色附件的混合状态使能标志变量。 |
Parameters
Name |
Description |
|---|---|
index |
整数类型颜色附件索引。 |
bEnable |
混合状态使能标志变量。
|
Method |
|---|
bool GetBlendingEnable(u32 index) const 获取指定颜色附件的混合状态使能标志变量。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetSrcColorBlend(u32 index, BlendFactor srcColorBlend) 设置指定颜色附件的源颜色通道混合系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
srcColorBlend |
源颜色通道混合系数。 |
Method |
|---|
BlendFactor GetSrcColorBlend(u32 index) const 获取指定颜色附件的源颜色通道混合系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的源颜色通道混合系数。 |
Method |
|---|
void SetDstColorBlend(u32 index, BlendFactor dstColorBlend) 设置指定颜色附件的目标颜色通道混合系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
dstColorBlend |
目标颜色通道混合系数。 |
Method |
|---|
BlendFactor GetDstColorBlend(u32 index) const 获取指定颜色附件的目标颜色通道混合系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的目标颜色通道混合系数。 |
Method |
|---|
void SetColorBlendOperation(u32 index, BlendOperation colorBlendOp) 设置指定颜色附件的颜色混合操作。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
colorBlendOp |
颜色混合操作枚举值。 |
Method |
|---|
BlendOperation GetColorBlendOperation(u32 index) const 获取指定颜色附件的颜色混合操作。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的颜色混合操作枚举值。 |
Method |
|---|
void SetSrcAlphaBlend(u32 index, BlendFactor srcAlphaBlend) 设置指定颜色附件的源Alpha通道系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
srcAlphaBlend |
指定颜色附件的源Alpha通道系数。 |
Method |
|---|
BlendFactor GetSrcAlphaBlend(u32 index) const 获取指定颜色附件的源Alpha通道系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的源Alpha通道系数。 |
Method |
|---|
void SetDstAlphaBlend(u32 index, BlendFactor dstAlphaBlend) 设置指定颜色附件的目标Alpha通道系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
dstAlphaBlend |
指定颜色附件的目标Alpha通道系数。 |
Method |
|---|
BlendFactor GetDstAlphaBlend(u32 index) const 获取指定颜色附件的目标Alpha通道系数。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的目标Alpha通道系数。 |
Method |
|---|
void SetAlphaBlendOperation(u32 index, BlendOperation alphaBlendOp) 设置指定颜色附件的Alpha通道混合操作。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
alphaBlendOp |
Alpha通道混合操作枚举值。请参见BlendOperation。 |
Method |
|---|
BlendOperation GetAlphaBlendOperation(u32 index) const 获取指定颜色附件的Alpha通道混合操作。 |
Parameters
Name |
Description |
|---|---|
index |
颜色附件索引。 |
Returns
Type |
Description |
|---|---|
指定颜色附件的Alpha通道混合操作枚举值。 |