37 lines
1.0 KiB
Markdown
37 lines
1.0 KiB
Markdown
# RHICommandList::SetBlendState
|
|
|
|
```cpp
|
|
virtual void SetBlendState(const BlendState& state) = 0;
|
|
```
|
|
|
|
设置颜色混合状态。控制源颜色和目标颜色如何混合,影响最终输出像素的颜色值。
|
|
|
|
**参数:**
|
|
- `state` - 混合状态结构体(包含 alphaToCoverageEnable、independentBlendEnable、renderTargets[] 等)
|
|
|
|
**返回:** `void`
|
|
|
|
**异常:** 无
|
|
|
|
**线程安全:** ❌
|
|
|
|
**复杂度:** O(1)
|
|
|
|
**示例:**
|
|
|
|
```cpp
|
|
BlendState blendState;
|
|
blendState.alphaToCoverageEnable = false;
|
|
blendState.independentBlendEnable = false;
|
|
blendState.renderTargets[0].blendEnable = true;
|
|
blendState.renderTargets[0].srcBlend = BlendFactor::SrcAlpha;
|
|
blendState.renderTargets[0].dstBlend = BlendFactor::InvSrcAlpha;
|
|
blendState.renderTargets[0].blendOp = BlendOp::Add;
|
|
cmdList->SetBlendState(blendState);
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [RHICommandList 总览](command-list.md) - 返回类总览
|
|
- [SetBlendFactor](set-blend-factor.md) - 设置混合因子
|
|
- [SetPipelineState](set-pipeline-state.md) - 设置管线状态 |