vault backup: 2024-10-03 09:17:08

This commit is contained in:
BlueRose 2024-10-03 09:17:08 +08:00
parent b834f90bf8
commit bc1cd5dafe

View File

@ -59,18 +59,24 @@ SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit,0);
- uint32 StencilRef = 0; - uint32 StencilRef = 0;
### FRHIBlendState ### FRHIBlendState
使用***FBlendStateInitializerRHI()*** 进行初始化。
它定义了8个渲染对象一般我们只用第一组它的七个参数分别是 它定义了8个渲染对象一般我们只用第一组它的七个参数分别是
- 颜色写入蒙版 - Color
- 颜色混合运算 - Color Write Mask
- 颜色源混合因子 - Color Blend 混合类型
- 颜色目标混合因子 - Color Src 混合因子
- Alpha混合运算 - Color Dest 混合因子
- Alpha源混合因子 - Alpha
- Alpha目标混合因子 - Alpha Blend 混合类型
- Alpha Src 混合因子
- Alpha Dest 混合因子
```c++
FRHIBlendState* CopyBlendState = TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_One>::GetRHI();
```
颜色写入蒙版: 颜色写入蒙版:
```c++
```text
enum EColorWriteMask enum EColorWriteMask
{ {
CW_RED = 0x01, CW_RED = 0x01,
@ -88,44 +94,39 @@ enum EColorWriteMask
}; };
``` ```
要继续讲解其他参数需要先列出DirectX的[混合方程](https://zhida.zhihu.com/search?content_id=217472065&content_type=Article&match_order=1&q=%E6%B7%B7%E5%90%88%E6%96%B9%E7%A8%8B&zhida_source=entity)作为参照:
C = C_{src} \otimes F_{src} \oplus C_{dst} \otimes F_{dst}_C_=_Csrc_⊗_Fsrc_⊕_Cdst_⊗_Fdst_A = A_{src} \otimes F_{src} \oplus A_{dst} \otimes F_{dst}_A_=_Asrc_⊗_Fsrc_⊕_Adst_⊗_Fdst_
第一个是颜色的混合方程第二个是Alpha的混合方程。
### 混合运算 ### 混合运算
混合运算符对于颜色混合方程和Alpha混合方程效果是一样的这里就只用颜色混合方程来做讲解。 混合运算符对于颜色混合方程和Alpha混合方程效果是一样的这里就只用颜色混合方程来做讲解。
|BlendOperation|颜色混合方程| | BlendOperation | 颜色混合方程 |
|---|---| | -------------------- | ---------------------------------------------------------------------------------- |
|BO_Add|C_{src} \otimes F_{src} + C_{dst} \otimes F_{dst}Csrc⊗Fsrc+Cdst⊗Fdst| | BO_Add | $$C=C_{src} \otimes F_{src} + C_{dst} \otimes F_{dst}Csrc⊗Fsrc+Cdst⊗Fdst$$ |
|BO_Subtract|C = C_{src} \otimes F_{src} - C_{dst} \otimes F_{dst}C=Csrc⊗FsrcCdst⊗Fdst| | BO_Subtract | $$C = C_{src} \otimes F_{src} - C_{dst} \otimes F_{dst}C=Csrc⊗FsrcCdst⊗Fdst$$ |
|BO_ReverseSubtract|C = C_{dst} \otimes F_{dst} - C_{src} \otimes F_{src}C=Cdst⊗FdstCsrc⊗Fsrc| | BO_ReverseSubtract | $$C = C_{dst} \otimes F_{dst} - C_{src} \otimes F_{src}C=Cdst⊗FdstCsrc⊗Fsrc$$ |
|BO_Min|C = Min(C_{src} , C_{dst} )C=Min(Csrc,Cdst)| | BO_Min | $$C = Min(C_{src} , C_{dst} )C=Min(Csrc,Cdst)$$ |
|BO_Max|C = Max(C_{src} , C_{dst} )C=Max(Csrc,Cdst)| | BO_Max | $$C = Max(C_{src} , C_{dst} )C=Max(Csrc,Cdst)$$ |
|BO_Min和BO_Max忽略了混合因子|| | BO_Min和BO_Max忽略了混合因子 | |
### 混合因子 ### 混合因子
| BlendFactor | 颜色混合因子 | Alpha混合因子 | | BlendFactor | 颜色混合因子 | Alpha混合因子 |
| ----------------------------- | ------------------------------------------------------------ | -------------------- | | ----------------------------- | ---------------------------------------------------------------- | ------------------------ |
| BF_Zero | F = (0,0,0)F=(0,0,0) | F=0F=0 | | BF_Zero | $$F = (0,0,0)F=(0,0,0)$$ | $$F=0F=0$$ |
| BF_One | F=(1,1,1)F=(1,1,1) | F=1F=1 | | BF_One | $$F=(1,1,1)F=(1,1,1)$$ | $$F=1F=1$$ |
| BF_SourceColor | F=(r_{src},g_{src},b_{src})F=(rsrc,gsrc,bsrc) | | | BF_SourceColor | $$F=(r_{src},g_{src},b_{src})F=(rsrc,gsrc,bsrc)$$ | |
| BF_InverseSourceColor | F=(1-r_{src},1-g_{src},1-b_{src})F=(1rsrc,1gsrc,1bsrc) | | | BF_InverseSourceColor | $$F=(1-r_{src},1-g_{src},1-b_{src})F=(1rsrc,1gsrc,1bsrc)$$ | |
| BF_SourceAlpha | F=(a_{src},a_{src},a_{src})F=(asrc,asrc,asrc) | F=a_{src}F=asrc | | BF_SourceAlpha | $$F=(a_{src},a_{src},a_{src})F=(asrc,asrc,asrc)$$ | $$F=a_{src}F=asrc$$ |
| BF_InverseSourceAlpha | F=(1-a_{src},1-a_{src},1-a_{src})F=(1asrc,1asrc,1asrc) | F=1-a_{src}F=1asrc | | BF_InverseSourceAlpha | $$F=(1-a_{src},1-a_{src},1-a_{src})F=(1asrc,1asrc,1asrc)$$ | $$F=1-a_{src}F=1asrc$$ |
| BF_DestAlpha | F=(a_{dst},a_{dst},a_{dst})F=(adst,adst,adst) | F=a_{dst}F=adst | | BF_DestAlpha | $$F=(a_{dst},a_{dst},a_{dst})F=(adst,adst,adst)$$ | $$F=a_{dst}F=adst$$ |
| BF_InverseDestAlpha | F=(1-a_{dst},1-a_{dst},1-a_{dst})F=(1adst,1adst,1adst) | F=1-a_{dst}F=1adst | | BF_InverseDestAlpha | $$F=(1-a_{dst},1-a_{dst},1-a_{dst})F=(1adst,1adst,1adst)$$ | $$F=1-a_{dst}F=1adst$$ |
| BF_DestColor | F=(r_{dst},g_{dst},b_{dst})F=(rdst,gdst,bdst) | | | BF_DestColor | $$F=(r_{dst},g_{dst},b_{dst})F=(rdst,gdst,bdst)$$ | |
| BF_InverseDestColor | F=(1-r_{dst},1-g_{dst},1-b_{dst})F=(1rdst,1gdst,1bdst) | | | BF_InverseDestColor | $$F=(1-r_{dst},1-g_{dst},1-b_{dst})F=(1rdst,1gdst,1bdst)$$ | |
| BF_ConstantBlendFactor | F=(r,g,b)F=(r,g,b) | F=aF=a | | BF_ConstantBlendFactor | F=(r,g,b)F=(r,g,b) | F=aF=a |
| BF_InverseConstantBlendFactor | F=(1-r,1-g,1-b)F=(1r,1g,1b) | F=1-aF=1a | | BF_InverseConstantBlendFactor | F=(1-r,1-g,1-b)F=(1r,1g,1b) | F=1-aF=1a |
| BF_Source1Color | 未知 | 未知 | | BF_Source1Color | 未知 | 未知 |
| BF_InverseSource1Color | 未知 | 未知 | | BF_InverseSource1Color | 未知 | 未知 |
| BF_Source1Alpha | 未知 | 未知 | | BF_Source1Alpha | 未知 | 未知 |
| BF_InverseSource1Alpha | 未知 | 未知 | | BF_InverseSource1Alpha | 未知 | 未知 |
最后四个选项没有在DirectX中找到对应的选项没有继续探究前面的应该足够一般使用了。 最后四个选项没有在DirectX中找到对应的选项没有继续探究前面的应该足够一般使用了。
### FRHIDepthStencilState ### FRHIDepthStencilState