summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-03-28 17:25:36 -0700
committeryum <yum.food.vr@gmail.com>2025-03-28 17:25:36 -0700
commit1e351cecd990cc25f2d3af76c52a613ad539c299 (patch)
treefe5aabd95dbb13685cf3e65a4c441b6c6dac5e9d
parent2c9e02770250a3f3e781a2fb22357e0a910a2436 (diff)
Add time controls to shatterwave chronotensity feature
-rw-r--r--2ner.shader1
-rw-r--r--globals.cginc1
-rw-r--r--shatter_wave.cginc50
3 files changed, 17 insertions, 35 deletions
diff --git a/2ner.shader b/2ner.shader
index 9840230..c131afe 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -522,6 +522,7 @@ Shader "yum_food/2ner"
_Shatter_Wave_Chronotensity_Weights1("Chronotensity weights (wave 1)", Vector) = (0, 0, 0, 0)
_Shatter_Wave_Chronotensity_Weights2("Chronotensity weights (wave 2)", Vector) = (0, 0, 0, 0)
_Shatter_Wave_Chronotensity_Weights3("Chronotensity weights (wave 3)", Vector) = (0, 0, 0, 0)
+ _Shatter_Wave_Chronotensity_Time_Factor("Chronotensity time factor", Vector) = (1, 1, 1, 1)
[HideInInspector] m_end_Shatter_Wave_Audiolink("Audiolink", Float) = 0
[HideInInspector] m_start_Shatter_Wave_Rotation("Rotation", Float) = 0
[ThryToggle(_SHATTER_WAVE_ROTATION)] _Shatter_Wave_Rotation_Enabled("Enable", Float) = 0
diff --git a/globals.cginc b/globals.cginc
index 5f891c3..74aa9ea 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -434,6 +434,7 @@ float4 _Shatter_Wave_Chronotensity_Weights0;
float4 _Shatter_Wave_Chronotensity_Weights1;
float4 _Shatter_Wave_Chronotensity_Weights2;
float4 _Shatter_Wave_Chronotensity_Weights3;
+float4 _Shatter_Wave_Chronotensity_Time_Factor;
#endif // _SHATTER_WAVE_AUDIOLINK
#if defined(_SHATTER_WAVE_ROTATION)
diff --git a/shatter_wave.cginc b/shatter_wave.cginc
index aae45ef..8975908 100644
--- a/shatter_wave.cginc
+++ b/shatter_wave.cginc
@@ -21,51 +21,31 @@ void shatterWaveVert(inout float3 objPos, float3 objNormal, float3 objTangent) {
objPos_proj[2] = dot(objPos, wave_axis2) * normalize(wave_axis2);
objPos_proj[3] = dot(objPos, wave_axis3) * normalize(wave_axis3);
- float4 wave_t = _Time[0] * _Shatter_Wave_Speed;
#if defined(_SHATTER_WAVE_AUDIOLINK)
+ float4 wave_t;
+ [branch]
if (AudioLinkIsAvailable()) {
const uint chrono_time_scale_i = 1000 * 1000;
const float chrono_time_scale_f = 1000 * 1000;
// For some fucking reason the compiler shits itself if this is a loop.
+ float4 chrono_t = 0;
+ [unroll]
+ for (uint band = 0; band < 4; ++band)
{
- uint band = 0;
- uint chrono_raw = AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(0, band));
- float chrono_normalized = (chrono_raw % chrono_time_scale_i) / chrono_time_scale_f;
- wave_t.x = _Shatter_Wave_Chronotensity_Weights0[band] * chrono_normalized;
- wave_t.y = _Shatter_Wave_Chronotensity_Weights1[band] * chrono_normalized;
- wave_t.z = _Shatter_Wave_Chronotensity_Weights2[band] * chrono_normalized;
- wave_t.w = _Shatter_Wave_Chronotensity_Weights3[band] * chrono_normalized;
- }
- {
- uint band = 1;
- uint chrono_raw = AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(0, band));
- float chrono_normalized = (chrono_raw % chrono_time_scale_i) / chrono_time_scale_f;
- wave_t.x += _Shatter_Wave_Chronotensity_Weights0[band] * chrono_normalized;
- wave_t.y += _Shatter_Wave_Chronotensity_Weights1[band] * chrono_normalized;
- wave_t.z += _Shatter_Wave_Chronotensity_Weights2[band] * chrono_normalized;
- wave_t.w += _Shatter_Wave_Chronotensity_Weights3[band] * chrono_normalized;
- }
- {
- uint band = 2;
- uint chrono_raw = AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(0, band));
+ uint chrono_raw = AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(6, band));
float chrono_normalized = (chrono_raw % chrono_time_scale_i) / chrono_time_scale_f;
- wave_t.x += _Shatter_Wave_Chronotensity_Weights0[band] * chrono_normalized;
- wave_t.y += _Shatter_Wave_Chronotensity_Weights1[band] * chrono_normalized;
- wave_t.z += _Shatter_Wave_Chronotensity_Weights2[band] * chrono_normalized;
- wave_t.w += _Shatter_Wave_Chronotensity_Weights3[band] * chrono_normalized;
- }
- {
- uint band = 3;
- uint chrono_raw = AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(0, band));
- float chrono_normalized = (chrono_raw % chrono_time_scale_i) / chrono_time_scale_f;
- wave_t.x += _Shatter_Wave_Chronotensity_Weights0[band] * chrono_normalized;
- wave_t.y += _Shatter_Wave_Chronotensity_Weights1[band] * chrono_normalized;
- wave_t.z += _Shatter_Wave_Chronotensity_Weights2[band] * chrono_normalized;
- wave_t.w += _Shatter_Wave_Chronotensity_Weights3[band] * chrono_normalized;
+ chrono_t.x += _Shatter_Wave_Chronotensity_Weights0[band] * chrono_normalized;
+ chrono_t.y += _Shatter_Wave_Chronotensity_Weights1[band] * chrono_normalized;
+ chrono_t.z += _Shatter_Wave_Chronotensity_Weights2[band] * chrono_normalized;
+ chrono_t.w += _Shatter_Wave_Chronotensity_Weights3[band] * chrono_normalized;
}
+ wave_t = chrono_t * _Shatter_Wave_Chronotensity_Time_Factor;
+ wave_t = fmod(wave_t, 10) - 10 * 0.5;
}
-#endif
+#else
+ float4 wave_t = _Time[0] * _Shatter_Wave_Speed;
wave_t = fmod(wave_t + _Shatter_Wave_Time_Offset * _Shatter_Wave_Period, _Shatter_Wave_Period) - _Shatter_Wave_Period * 0.5;
+#endif
float4 wave_center = wave_t;