summaryrefslogtreecommitdiffstats
path: root/vertex.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-10-28 16:07:36 -0700
committeryum <yum.food.vr@gmail.com>2025-10-28 17:19:38 -0700
commitfd370eab7e4959895763514526efc878e53d4886 (patch)
tree5ecb9f4d1710f737f96f68a6ab7d7b80e5d6c4d0 /vertex.cginc
parent0af84f011446496dd85a1cc6b139121ac99b139b (diff)
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.
Diffstat (limited to 'vertex.cginc')
-rw-r--r--vertex.cginc29
1 files changed, 17 insertions, 12 deletions
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,