vault backup: 2026-05-03 20:37:58
This commit is contained in:
136
03-UnrealEngine/卡通渲染相关资料/渲染功能/ARC/Rendering/自定义后处理.md
Normal file
136
03-UnrealEngine/卡通渲染相关资料/渲染功能/ARC/Rendering/自定义后处理.md
Normal file
@@ -0,0 +1,136 @@
|
||||
---
|
||||
title: 自定义后处理
|
||||
date: 2026-05-03 00:00:00
|
||||
excerpt: REDPostProcess 全套自定义后处理:Diffusion Filter、角色辉光、自定义 DOF
|
||||
tags:
|
||||
- ARC
|
||||
- Rendering
|
||||
- PostProcess
|
||||
- Toon
|
||||
rating: ⭐
|
||||
---
|
||||
|
||||
# 自定义后处理
|
||||
|
||||
返回 [[Rendering]]
|
||||
|
||||
## 概述
|
||||
|
||||
ARC 引擎新增了完整的自定义后处理系统(REDPostProcess),提供 Diffusion Filter(扩散滤镜)、角色辉光(Chara Glow)和自定义景深(DOF)三大功能。这些效果专门为动画风格渲染设计,与标准 UE4 后处理管线并行工作。
|
||||
|
||||
## Shader 端:REDPostProcess.usf
|
||||
|
||||
### Diffusion Filter(扩散滤镜)
|
||||
|
||||
基于亮度的柔焦/辉光效果,使用 13-tap 高斯模糊(7 权重核):
|
||||
|
||||
```hlsl
|
||||
// 从场景颜色提取高亮区域
|
||||
float Luminance = dot(SceneColor.rgb, float3(0.299, 0.587, 0.114));
|
||||
float LuminanceMask = pow(Luminance, LuminancePow);
|
||||
LuminanceMask = saturate(LuminanceMask - LuminanceThreshold);
|
||||
|
||||
// 高斯模糊后以 Screen 混合模式叠加
|
||||
// Screen blend: 1 - (1-A)(1-B)
|
||||
float3 Result = 1.0 - (1.0 - SceneColor.rgb) * (1.0 - BlurredHighlight);
|
||||
```
|
||||
|
||||
可调参数:
|
||||
- `DiffusionFilterLuminancePow` — 亮度幂次(控制提取范围)
|
||||
- `DiffusionFilterLuminanceThreshold` — 亮度阈值
|
||||
|
||||
### Diffusion Filter 2(变体)
|
||||
|
||||
```hlsl
|
||||
// Screen 混合 + Power 调整
|
||||
float3 BlendResult = 1.0 - (1.0 - A) * (1.0 - B);
|
||||
Result = pow(BlendResult, Power);
|
||||
```
|
||||
|
||||
### 角色辉光(Chara Glow)
|
||||
|
||||
从 GBufferD 的 B 通道读取 OutlineID 作为辉光遮罩,进行可变半径的 Box Blur:
|
||||
|
||||
```hlsl
|
||||
// 读取 GBufferD.b 作为遮罩
|
||||
float Mask = GBufferD.b;
|
||||
|
||||
// 可变半径 Box Blur
|
||||
for (int y = -Radius; y <= Radius; y++)
|
||||
for (int x = -Radius; x <= Radius; x++)
|
||||
Sum += SampleMask(UV + offset);
|
||||
|
||||
// 以 CharaGlowColor 叠加
|
||||
OutColor = Sum * CharaGlowColor * CharaGlowArea;
|
||||
```
|
||||
|
||||
可调参数:
|
||||
- `CharaGlowArea` — 辉光范围
|
||||
- `CharaGlowColor` — 辉光颜色
|
||||
|
||||
### 自定义 DOF
|
||||
|
||||
替代标准 DOF 的 RED 专用版本,支持近景/远景独立模糊:
|
||||
|
||||
```hlsl
|
||||
// 高斯模糊 Pass(水平 + 垂直分离)
|
||||
// 13-tap 核,权重:0.0044, 0.0540, 0.2420, 0.3990, ...
|
||||
```
|
||||
|
||||
### Soft Focus / Glow / Sepia
|
||||
|
||||
其他后处理变体:
|
||||
- **Soft Focus**:场景与模糊版本的简单混合 + 饱和度控制
|
||||
- **Glow**:亮度阈值 + Screen 混合辉光
|
||||
- **Sepia**:Diffusion Filter 2 的棕褐色变体
|
||||
|
||||
## C++ 端:REDPostProcess.h/.cpp
|
||||
|
||||
### 后处理 Pass 类型
|
||||
|
||||
```cpp
|
||||
// 4 种主要 Pass
|
||||
enum class EREDPostProcessPass
|
||||
{
|
||||
DiffusionFilter, // 扩散滤镜
|
||||
CharaGlow, // 角色辉光
|
||||
DownSample, // 降采样
|
||||
BlurH, BlurV, // 水平/垂直高斯模糊
|
||||
CustomGaussianDOF // 自定义 DOF
|
||||
};
|
||||
```
|
||||
|
||||
### 插入点控制
|
||||
|
||||
通过 CVar 控制后处理在管线中的插入位置:
|
||||
|
||||
```cpp
|
||||
// r.REDPostprocessAfterTranslucency
|
||||
// 0 = 在 SeparateTranslucency 之前
|
||||
// 1 = 在 SeparateTranslucency 之后
|
||||
// 2 = 在 Bloom 之后
|
||||
```
|
||||
|
||||
### PostProcessSettings 扩展
|
||||
|
||||
```cpp
|
||||
// Scene.h 新增
|
||||
float DiffusionFilterLuminancePow;
|
||||
float DiffusionFilterLuminanceThreshold;
|
||||
float CharaGlowArea;
|
||||
FLinearColor CharaGlowColor;
|
||||
```
|
||||
|
||||
## 关联文档
|
||||
|
||||
- [[RED自定义数据通道]] — CharaGlow 读取 GBufferD.b 通道
|
||||
- [[BGMultColor全局色调]] — 另一个全局色彩控制系统
|
||||
|
||||
## 修改文件列表
|
||||
|
||||
| 文件 | 修改类型 |
|
||||
|------|---------|
|
||||
| `Shaders/Private/REDPostProcess.usf` | **新增** — 完整后处理着色器 |
|
||||
| `Source/Runtime/Renderer/Private/PostProcess/REDPostProcess.h` | **新增** — C++ 后处理 Pass |
|
||||
| `Source/Runtime/Renderer/Private/PostProcess/REDPostProcess.cpp` | **新增** — C++ 实现 |
|
||||
| `Source/Runtime/Engine/Classes/Engine/Scene.h` | 新增 PostProcess 参数 |
|
||||
Reference in New Issue
Block a user