Files
BlueRoseNote/03-UnrealEngine/卡通渲染相关资料/渲染功能/ARC/Rendering/屏幕空间深度偏移.md

50 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 屏幕空间深度偏移
date: 2026-05-03 00:00:00
excerpt: 在屏幕空间偏移顶点深度,防止 Z-fighting 或强制分层
tags:
- ARC
- Rendering
- VertexFactory
rating: ⭐
---
# 屏幕空间深度偏移
返回 [[Rendering]]
## 概述
在顶点着色器中直接偏移输出深度值,用于防止卡通描边的 Z-fighting 或强制控制元素的渲染层级。
## 实现
```hlsl
#if USES_SCREEN_SPACE_DEPTH_OFFSET
{
Output.Position.z += GetMaterialScreenSpaceDepthOffset(VertexParameters)
* DEPTH_OFFSET_SIGN;
}
#endif
```
`DEPTH_OFFSET_SIGN` 根据平台的深度缓冲方向(正向/反向 Z自动调整符号。
## 使用场景
- 卡通描边网格的深度偏移(避免与本体 Z-fighting
- 半透明元素的强制排序
- 面部特征的深度分层(眉毛、头发等)
## 材质属性
`MP_ScreenSpaceDepthOffset`float通过材质图控制。参见 [[自定义材质属性]]。
## 修改文件列表
| 文件 | 修改类型 |
|------|---------|
| `Shaders/Private/BasePassVertexShader.usf` | 深度偏移逻辑 |
| `Shaders/Private/DepthOnlyVertexShader.usf` | 同上 |
| `Shaders/Private/PositionOnlyDepthVertexShader.usf` | 同上 |