From fd370eab7e4959895763514526efc878e53d4886 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 28 Oct 2025 16:07:36 -0700 Subject: add logical time feature the idea is that a remote piece of software s.a. TiXL sends in its logical time every once in a while. udon recovers it, interpolates and smooths it, and feeds it to the shader. Anything which is periodic on units of 1.0 "seconds" retains its periodicity under changes to the rate of passage of time. --- vertex.cginc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'vertex.cginc') diff --git a/vertex.cginc b/vertex.cginc index eba7031..b5750c6 100644 --- a/vertex.cginc +++ b/vertex.cginc @@ -1,11 +1,14 @@ #ifndef __VERTEX_INC #define __VERTEX_INC +#include "globals.cginc" #include "vertex_deformation.hlsl" #define FOO(x) (x) void deform(inout float3 objPos) { + const float t = getTime(); + #if defined(_VERTEX_DEFORMATION_XZ_TUBE) { float t = _Vertex_Deformation_XZ_Tube_t; @@ -30,23 +33,23 @@ void deform(inout float3 objPos) { { float A = _Vertex_Deformation_Seal_A; float k = _Vertex_Deformation_Seal_k; - float t = _Time[3] * _Vertex_Deformation_Seal_t; - objPos = seal(objPos.xyz, A, k, t); + float st = t * _Vertex_Deformation_Seal_t; + objPos = seal(objPos.xyz, A, k, st); } #endif // _VERTEX_DEFORMATION_SEAL #if defined(_VERTEX_DEFORMATION_SINE_WAVES) { - float t = _Time[3]; + float st = t * 10; float3 amplitude = _Vertex_Deformation_Sine_Waves_Amplitude; float3 direction = _Vertex_Deformation_Sine_Waves_Direction; float3 k = _Vertex_Deformation_Sine_Waves_k; float3 omega = _Vertex_Deformation_Sine_Waves_omega; - objPos = sine_wave(objPos.xyz, amplitude, direction, k, omega, t); + objPos = sine_wave(objPos.xyz, amplitude, direction, k, omega, st); } #endif // _VERTEX_DEFORMATION_SINE_WAVES #if defined(_VERTEX_DEFORMATION_FBM) { - float t = _Time[3]; + float st = t; float amplitude = _Vertex_Deformation_FBM_Amplitude; float gain = _Vertex_Deformation_FBM_Gain; float lacunarity = _Vertex_Deformation_FBM_Lacunarity; @@ -55,7 +58,7 @@ void deform(inout float3 objPos) { float3 velocity = _Vertex_Deformation_FBM_Velocity; objPos = fbm( objPos, - t, + st, amplitude, gain, lacunarity, @@ -67,6 +70,8 @@ void deform(inout float3 objPos) { } void deform_normal(float3 objPos, inout float3 objNorm, inout float3 objTan) { + const float t = getTime(); + #if defined(_VERTEX_DEFORMATION_XZ_TUBE) { float t = _Vertex_Deformation_XZ_Tube_t; @@ -89,23 +94,23 @@ void deform_normal(float3 objPos, inout float3 objNorm, inout float3 objTan) { { float A = _Vertex_Deformation_Seal_A; float k = _Vertex_Deformation_Seal_k; - float t = _Time[3] * _Vertex_Deformation_Seal_t; - seal_normal(objPos, objNorm, objTan, A, k, t); + float st = t * _Vertex_Deformation_Seal_t; + seal_normal(objPos, objNorm, objTan, A, k, st); } #endif // _VERTEX_DEFORMATION_SEAL #if defined(_VERTEX_DEFORMATION_SINE_WAVES) { - float t = _Time[3]; + float st = t * 10; float3 amplitude = _Vertex_Deformation_Sine_Waves_Amplitude; float3 direction = _Vertex_Deformation_Sine_Waves_Direction; float3 k = _Vertex_Deformation_Sine_Waves_k; float3 omega = _Vertex_Deformation_Sine_Waves_omega; - sine_wave_normal(objPos, objNorm, objTan, amplitude, direction, k, omega, t); + sine_wave_normal(objPos, objNorm, objTan, amplitude, direction, k, omega, st); } #endif // _VERTEX_DEFORMATION_SINE_WAVES #if defined(_VERTEX_DEFORMATION_FBM) { - float t = _Time[3]; + float st = t; float amplitude = _Vertex_Deformation_FBM_Amplitude; float gain = _Vertex_Deformation_FBM_Gain; float lacunarity = _Vertex_Deformation_FBM_Lacunarity; @@ -116,7 +121,7 @@ void deform_normal(float3 objPos, inout float3 objNorm, inout float3 objTan) { objPos, objNorm, objTan, - t, + st, amplitude, gain, lacunarity, -- cgit v1.2.3