vault backup: 2024-10-03 09:17:08
This commit is contained in:
parent
b834f90bf8
commit
bc1cd5dafe
@ -59,18 +59,24 @@ SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit,0);
|
||||
- uint32 StencilRef = 0;
|
||||
|
||||
### FRHIBlendState
|
||||
使用***FBlendStateInitializerRHI()*** 进行初始化。
|
||||
它定义了8个渲染对象,一般我们只用第一组,它的七个参数分别是:
|
||||
- 颜色写入蒙版
|
||||
- 颜色混合运算
|
||||
- 颜色源混合因子
|
||||
- 颜色目标混合因子
|
||||
- Alpha混合运算
|
||||
- Alpha源混合因子
|
||||
- Alpha目标混合因子
|
||||
- Color
|
||||
- Color Write Mask
|
||||
- Color Blend 混合类型
|
||||
- Color Src 混合因子
|
||||
- Color Dest 混合因子
|
||||
- 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();
|
||||
```
|
||||
|
||||
颜色写入蒙版:
|
||||
|
||||
```text
|
||||
```c++
|
||||
enum EColorWriteMask
|
||||
{
|
||||
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混合方程效果是一样的,这里就只用颜色混合方程来做讲解。
|
||||
|
||||
|BlendOperation|颜色混合方程|
|
||||
|---|---|
|
||||
|BO_Add|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⊗Fsrc−Cdst⊗Fdst|
|
||||
|BO_ReverseSubtract|C = C_{dst} \otimes F_{dst} - C_{src} \otimes F_{src}C=Cdst⊗Fdst−Csrc⊗Fsrc|
|
||||
|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_Min和BO_Max忽略了混合因子||
|
||||
| BlendOperation | 颜色混合方程 |
|
||||
| -------------------- | ---------------------------------------------------------------------------------- |
|
||||
| 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⊗Fsrc−Cdst⊗Fdst$$ |
|
||||
| BO_ReverseSubtract | $$C = C_{dst} \otimes F_{dst} - C_{src} \otimes F_{src}C=Cdst⊗Fdst−Csrc⊗Fsrc$$ |
|
||||
| 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_Min和BO_Max忽略了混合因子 | |
|
||||
|
||||
### 混合因子
|
||||
|
||||
| BlendFactor | 颜色混合因子 | Alpha混合因子 |
|
||||
| ----------------------------- | ------------------------------------------------------------ | -------------------- |
|
||||
| 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_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=(1−rsrc,1−gsrc,1−bsrc) | – |
|
||||
| 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=(1−asrc,1−asrc,1−asrc) | F=1-a_{src}F=1−asrc |
|
||||
| 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=(1−adst,1−adst,1−adst) | F=1-a_{dst}F=1−adst |
|
||||
| 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=(1−rdst,1−gdst,1−bdst) | – |
|
||||
| BF_ConstantBlendFactor | F=(r,g,b)F=(r,g,b) | F=aF=a |
|
||||
| BF_InverseConstantBlendFactor | F=(1-r,1-g,1-b)F=(1−r,1−g,1−b) | F=1-aF=1−a |
|
||||
| BF_Source1Color | 未知 | 未知 |
|
||||
| BF_InverseSource1Color | 未知 | 未知 |
|
||||
| BF_Source1Alpha | 未知 | 未知 |
|
||||
| BF_InverseSource1Alpha | 未知 | 未知 |
|
||||
| BlendFactor | 颜色混合因子 | Alpha混合因子 |
|
||||
| ----------------------------- | ---------------------------------------------------------------- | ------------------------ |
|
||||
| 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_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=(1−rsrc,1−gsrc,1−bsrc)$$ | – |
|
||||
| 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=(1−asrc,1−asrc,1−asrc)$$ | $$F=1-a_{src}F=1−asrc$$ |
|
||||
| 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=(1−adst,1−adst,1−adst)$$ | $$F=1-a_{dst}F=1−adst$$ |
|
||||
| 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=(1−rdst,1−gdst,1−bdst)$$ | – |
|
||||
| BF_ConstantBlendFactor | F=(r,g,b)F=(r,g,b) | F=aF=a |
|
||||
| BF_InverseConstantBlendFactor | F=(1-r,1-g,1-b)F=(1−r,1−g,1−b) | F=1-aF=1−a |
|
||||
| BF_Source1Color | 未知 | 未知 |
|
||||
| BF_InverseSource1Color | 未知 | 未知 |
|
||||
| BF_Source1Alpha | 未知 | 未知 |
|
||||
| BF_InverseSource1Alpha | 未知 | 未知 |
|
||||
|
||||
最后四个选项没有在DirectX中找到对应的选项,没有继续探究,前面的应该足够一般使用了。
|
||||
### FRHIDepthStencilState
|
||||
|
Loading…
x
Reference in New Issue
Block a user