55 lines
1.4 KiB
Markdown
55 lines
1.4 KiB
Markdown
---
|
||
title: 局部位置缩放
|
||
date: 2026-05-03 00:00:00
|
||
excerpt: 逐材质局部空间顶点缩放
|
||
tags:
|
||
- ARC
|
||
- Rendering
|
||
- VertexFactory
|
||
rating: ⭐
|
||
---
|
||
|
||
# 局部位置缩放
|
||
|
||
返回 [[Rendering]]
|
||
|
||
## 概述
|
||
|
||
允许通过材质图在局部空间(Local Space)对顶点位置进行缩放,实现不依赖 Actor Transform 的比例调整。
|
||
|
||
## 实现
|
||
|
||
在各 VertexFactory 中通过 `VertexFactoryUpdateLocalPositionScale` 函数实现:
|
||
|
||
```hlsl
|
||
void VertexFactoryUpdateLocalPositionScale(
|
||
inout FVertexFactoryInput Input,
|
||
inout FVertexFactoryIntermediates Intermediates,
|
||
float3 scale)
|
||
{
|
||
Input.Position.xyz *= scale;
|
||
}
|
||
```
|
||
|
||
由 `USES_LOCAL_POSITION_SCALE` 宏控制启用,在世界变换之前应用。
|
||
|
||
## 使用场景
|
||
|
||
- 角色部件的动态缩放(如拳头放大的夸张动画效果)
|
||
- 不同 LOD 级别的微调
|
||
- 格斗游戏中攻击判定与视觉表现分离时的视觉调整
|
||
|
||
## 材质属性
|
||
|
||
`MP_LocalPositionScale`(float3)通过材质图控制。参见 [[自定义材质属性]]。
|
||
|
||
## 修改文件列表
|
||
|
||
| 文件 | 修改类型 |
|
||
|------|---------|
|
||
| `Shaders/Private/LocalVertexFactory.ush` | 新增缩放函数 |
|
||
| `Shaders/Private/GpuSkinVertexFactory.ush` | 同上 |
|
||
| `Shaders/Private/LandscapeVertexFactory.ush` | 同上 |
|
||
| `Shaders/Private/MeshParticleVertexFactory.ush` | 同上 |
|
||
| 所有 Particle VertexFactory | 同上 |
|