vault backup: 2025-04-13 20:25:30
This commit is contained in:
parent
c1b61e6352
commit
516c653073
@ -373,12 +373,13 @@ float3 ToneMappedColorAP1 = FilmToneMap( ColorAP1 );
|
||||
- UE4中添加自定义ComputerShader:https://zhuanlan.zhihu.com/p/413884878
|
||||
- UE渲染学习(2)- 自定义PostProcess - Kuwahara滤镜:https://zhuanlan.zhihu.com/p/25790491262
|
||||
|
||||
# 在if(bPostProcessingEnabled)代码段
|
||||
# 在UE5添加自定义后处理Pass的方法
|
||||
## 在if(bPostProcessingEnabled)代码段
|
||||
1. 在AddPostProcessingPasses()(PostProcessing.cpp)中的**EPass**与**PassNames**数组中添加Pass名称枚举与Pass名称字符串。
|
||||
2. 在**PassSequence.Finalize()** 之前,添加上一步EPass同名的`PassSequence.SetEnabled(EPass::XXX)` 。该逻辑用于控制对应Pass是否起作用。
|
||||
3. 根据步骤1中新增Pass的顺序,在对应的位置添加对应的代码段。额外需要注意的Tonemap前后的Pass代码有所不同。
|
||||
|
||||
## Pass代码
|
||||
### Pass代码
|
||||
1. `MotionBlur`之前(后处理材质BL_BeforeTonemapping之前),传入FScreenPassTexture SceneColor进行绘制。
|
||||
2. `MotionBlur`~`Tonemap`传入FScreenPassTextureSlice SceneColorSlice进行绘制。
|
||||
3. `Tonemap`之后,传入FScreenPassTexture SceneColor进行绘制。
|
||||
@ -407,12 +408,32 @@ if (PassSequence.IsEnabled(EPass::XXX))
|
||||
}
|
||||
```
|
||||
|
||||
## 超采样之后的UV转换
|
||||
### 超采样之后的UV转换
|
||||
`Tonemap`之后的Pass因为超采样的关系使得ViewportResoution与BufferResoution不同,所以需要使用`SHADER_PARAMETER(FScreenTransform, SvPositionToInputTextureUV)`以及`FScreenTransform::ChangeTextureBasisFromTo`计算变换比例。具体可以参考FFXAAPS。
|
||||
|
||||
SvPosition => ViewportUV => TextureUV:
|
||||
```c++
|
||||
PassParameters->SvPositionToInputTextureUV = (
|
||||
FScreenTransform::SvPositionToViewportUV(Output.ViewRect) *
|
||||
FScreenTransform::ChangeTextureBasisFromTo(FScreenPassTextureViewport(Inputs.SceneColorSlice), FScreenTransform::ETextureBasis::ViewportUV, FScreenTransform::ETextureBasis::TextureUV));
|
||||
```
|
||||
|
||||
之后在Shader中:
|
||||
```c++
|
||||
Texture2D SceneColorTexture;
|
||||
SamplerState SceneColorSampler;
|
||||
FScreenTransform SvPositionToInputTextureUV;
|
||||
|
||||
# 在else代码段
|
||||
void MainPS(
|
||||
float4 SvPosition : SV_POSITION,
|
||||
out float4 OutColor : SV_Target0)
|
||||
{
|
||||
float2 SceneColorUV = ApplyScreenTransform(SvPosition.xy, SvPositionToInputTextureUV);
|
||||
OutColor.rgba = SceneColorTexture.SampleLevel(SceneColorSampler, UV, 0).rgba;
|
||||
}
|
||||
```
|
||||
|
||||
## 在else代码段
|
||||
在else代码段中添加新Pass禁用代码段。不添加则会在切换到其他View(比如材质编辑器的Preview)时崩溃。例如:
|
||||
```c++
|
||||
if(bPostProcessingEnabled){
|
||||
|
Loading…
x
Reference in New Issue
Block a user