Tutorial
给汤米同学加膨胀和波浪效果
float d = length(@P);
d *= ch("v_scale");
d += @Time * ch("speed");
float func = fit(sin(d),-1,1,0,1);
@P += @N * func * ch("wave_height");
总结点的变换方程为 P = P + sin( a * |P| + b * Time) * N * c
a表示参数v_scale
b表示参数speed
c表示参数wave_height
|P|表示位置向量P的模
Time表示时间
这里将sin函数值范围从[-1,1]约束为[0,1]防止向内膨胀
改变参数wave_height效果:
改变参数v_scale效果:
clamp和fit函数的使用
clamp:
官方释义: Returns value clamped between min and max. 返回限制在最小值和最大值之间的值
用法: clamp(value, min, max)
fit:
官方释义: Takes the value in one range and shifts it to the corresponding value in a new range. 获取一个范围内[original_min, original_max]的值并将其转换为新范围内[new_min, new_max]的相应值。
用法: fit(value, omin, omax, nmin, nmax)
设置参数为可调节
Exercises
-
Try and incorporate clamp into the above setup, see if you can make it do something interesting.
试着把clamp合并到上面的设置中,看看你能不能让它做一些有趣的事情。 -
Set P based on waves generated from sin(d), but see what happens if you fit and clamp d before sin, after sine, or both before AND after sine.
设置P基于sin(d),尝试在sin之前fit和在sin之后clamp,或者在sin之前或之后fit和clamp会发生什么。 -
waves that start from 2 points and mix with each other (remember the earlier lesson about code style, and += *= vs =, and how you can accumulate results over several lines)
从2个点开始的波动并相互混合
-
try and build some of these examples with vops, see what feels faster.
vop学习中待补充~