diff options
| author | yum <yum.food.vr@gmail.com> | 2025-03-28 16:09:34 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-03-28 16:09:34 -0700 |
| commit | 2c9e02770250a3f3e781a2fb22357e0a910a2436 (patch) | |
| tree | 81b97b95878976f7f56703815fc59a0d23f87464 /shatter_wave.cginc | |
| parent | ac54b32eab582061b961c71efc8cdff28a4fa72e (diff) | |
add rotation to shatterwave
Diffstat (limited to 'shatter_wave.cginc')
| -rw-r--r-- | shatter_wave.cginc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/shatter_wave.cginc b/shatter_wave.cginc index 89b8e75..aae45ef 100644 --- a/shatter_wave.cginc +++ b/shatter_wave.cginc @@ -68,10 +68,24 @@ void shatterWaveVert(inout float3 objPos, float3 objNormal, float3 objTangent) { wave_t = fmod(wave_t + _Shatter_Wave_Time_Offset * _Shatter_Wave_Period, _Shatter_Wave_Period) - _Shatter_Wave_Period * 0.5;
float4 wave_center = wave_t;
- float4 offset;
+
+ // TODO calculate signed distance from wave center
+ float4 distance_signed;
+ for (uint i = 0; i < 4; i++) {
+ float3 dist_to_center = objPos_proj[i] - wave_center[i] * wave_axes[i];
+ distance_signed[i] = dot(dist_to_center, wave_axes[i]);
+ }
+
+#if defined(_SHATTER_WAVE_ROTATION)
+ float4 thetas = clamp(distance_signed * _Shatter_Wave_Rotation_Strength, -1, 1) * TAU;
+ for (uint i = 0; i < 4; i++) {
+ objPos = rotate_vector(objPos, get_quaternion(wave_axes[i], thetas[i]));
+ }
+#endif
+
for (uint i = 0; i < 4; i++) {
- offset[i] = exp(-length(objPos_proj[i] - wave_center[i] * wave_axes[i]) * _Shatter_Wave_Power[i]) * _Shatter_Wave_Amplitude[i];
- objPos += objNormal * offset[i];
+ float offset = exp(-abs(distance_signed[i]) * _Shatter_Wave_Power[i]) * _Shatter_Wave_Amplitude[i];
+ objPos += objNormal * offset;
}
}
|
