Saturate

等价于Clamp(Value, 0.0, 1.0)

DDX 、DDY

相当于GLSL中的dFdx、dFdy

ComputeFilterWidth

与fwidth类似,在UE中可以使用Custom节点使用HLSL调用fwidth

HLSL
// ComputeFilterWidth的实现
// float3 In 输入
// return float3
float3 dDX = ddx(In);
float3 dDY = ddy(In);
float3 A = dot(dDX, dDX);
float3 B = dot(dDY, dDY);
if (A > B)
	return sqrt(A);
else
	return sqrt(B);
点击展开查看更多

RotateAboutAxis

核心算法基于 罗德里格斯旋转公式 (Rodrigues’ Rotation Formula),该公式用于计算一个向量绕任意轴旋转后的新位置。

$$ \vec{v}_{rotated} = \vec{v}\cos(\theta) + (\vec{a} \times \vec{v})\sin(\theta) + \vec{a}(\vec{a} \cdot \vec{v})(1 - \cos(\theta)) $$
输入参数名称 数据类型 描述与算法作用
NormalizedRotationAxis Vector3 旋转轴方向(归一化)。定义物体绕哪根轴旋转。即公式中的$\vec{a}$。
RotationAngle Scalar 旋转角度。控制旋转的幅度。该输入接受的是 0.0 到 1.0 之间的数值,代表圆周的比例(即 $0 \sim 2\pi$ 弧度)。即公式中的$\theta$。
PivotPoint Vector3 旋转中心点。定义旋转发生的空间位置。
Position Vector3 输入位置坐标。需要被旋转的顶点的当前世界坐标。在公式中$\vec{v}=Position-PivotPoint$。
Period Scalar 周期/时间缩放因子,用于控制动画的速度或循环周期。

注意:该材质函数RotateAboutAxis输出的是位置偏移,即$\vec{v}_{rotated} - \vec{v}$。

版权声明

作者: Cheyne Xie

链接: https://chaim.eu.org/posts/8c3f6d09/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键