summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--3ner.shader10
-rw-r--r--3ner.shader.meta3
-rw-r--r--Scripts/DataDecoder.asset206
-rw-r--r--Scripts/DataDecoder.cs40
-rw-r--r--features.cginc4
-rw-r--r--globals.cginc14
-rw-r--r--pbr.cginc2
-rw-r--r--vertex.cginc29
8 files changed, 260 insertions, 48 deletions
diff --git a/3ner.shader b/3ner.shader
index 982faa7..457168b 100644
--- a/3ner.shader
+++ b/3ner.shader
@@ -43,7 +43,6 @@ Shader "yum_food/3ner"
//ifex _Geometry_Shader_Enabled==0
[HideInInspector] m_start_Geometry_Shader("Geometry Shader", Float) = 0
[ThryToggle(_GEOMETRY_SHADER)] _Geometry_Shader_Enabled("Enable", Float) = 0
-
//ifex _Center_Offset_Enabled==0
[HideInInspector] m_start_Center_Offset("Center offset", Float) = 0
[ThryToggle(_CENTER_OFFSET)] _Center_Offset_Enabled("Enable", Float) = 0
@@ -51,13 +50,20 @@ Shader "yum_food/3ner"
_Center_Offset_Factor("Factor", Range(-1, 1)) = 1
[HideInInspector] m_end_Center_Offset("Center offset", Float) = 0
//endex
-
[HideInInspector] m_end_Geometry_Shader("Geometry Shader", Float) = 0
//endex
+ //ifex _Logical_Time_Enabled==0
+ [HideInInspector] m_start_Logical_Time("Logical Time", Float) = 0
+ [ThryToggle(_LOGICAL_TIME)] _Logical_Time_Enabled("Enable", Float) = 0
+ _Logical_Time("Time", Float) = 0
+ [HideInInspector] m_end_Logical_Time("Logical Time", Float) = 0
+ //endex
+
//ifex _Vertex_Deformation_Enabled==0
[HideInInspector] m_start_Vertex_Deformation("Vertex Deformation", Float) = 0
[ThryToggle(_VERTEX_DEFORMATION)] _Vertex_Deformation_Enabled("Enable", Float) = 0
+
[ThryToggle(_VERTEX_DEFORMATION_FRAGMENT_NORMALS)] _Vertex_Deformation_Fragment_Normals_Enabled("Fragment normals", Float) = 0
[ThryToggle(_VERTEX_DEFORMATION_TESSELLATION)] _Vertex_Deformation_Tessellation_Enabled("Tesellation support", Float) = 1
diff --git a/3ner.shader.meta b/3ner.shader.meta
index 9aba81c..6cfcf99 100644
--- a/3ner.shader.meta
+++ b/3ner.shader.meta
@@ -6,10 +6,11 @@ ShaderImporter:
- _MainTex: {instanceID: 0}
- _BumpMap: {instanceID: 0}
- _MetallicGlossMap: {instanceID: 0}
+ - _Center_Offset_Heightmap: {instanceID: 0}
- _Marble_U_Ramp: {instanceID: 0}
- _Marble_V_Ramp: {instanceID: 0}
- _Marble_W_Ramp: {instanceID: 0}
- - _DFG_LUT: {fileID: 2800000, guid: d6fbf383c1bdb87439939bf17f69d539, type: 3}
+ - _DFG_LUT: {fileID: 2800000, guid: b6b1f1fa6be1ce54f8bcd5428c160a28, type: 3}
- _Cloth_Sheen_DFG_LUT: {fileID: 2800000, guid: 59729cfaee66a3c4d847e732c7f99272,
type: 3}
nonModifiableTextures: []
diff --git a/Scripts/DataDecoder.asset b/Scripts/DataDecoder.asset
index 26b5e70..b8be961 100644
--- a/Scripts/DataDecoder.asset
+++ b/Scripts/DataDecoder.asset
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: DataDecoder
m_EditorClassIdentifier:
- serializedUdonProgramAsset: {fileID: 11400000, guid: b63b58ca1fad83a46a36891e4e44e019,
+ serializedUdonProgramAsset: {fileID: 11400000, guid: 38593ce802cabb24286414629c53980c,
type: 2}
udonAssembly:
assemblyError:
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
- Data: 7
+ Data: 10
- Name:
Entry: 7
Data:
@@ -104,19 +104,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
- Data: tileToCheck
+ Data: target
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
- Data: tileToCheck
+ Data: target
- Name: <UserType>k__BackingField
Entry: 7
Data: 6|System.RuntimeType, mscorlib
- Name:
Entry: 1
- Data: System.Int32, mscorlib
+ Data: UnityEngine.MeshRenderer, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -166,11 +166,17 @@ MonoBehaviour:
Entry: 1
Data: tileSize
- Name: <UserType>k__BackingField
- Entry: 9
- Data: 6
+ Entry: 7
+ Data: 9|System.RuntimeType, mscorlib
+ - Name:
+ Entry: 1
+ Data: System.Int32, mscorlib
+ - Name:
+ Entry: 8
+ Data:
- Name: <SystemType>k__BackingField
Entry: 9
- Data: 6
+ Data: 9
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -185,7 +191,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
- Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ Data: 10|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -209,13 +215,13 @@ MonoBehaviour:
Data: pixelData
- Name: $v
Entry: 7
- Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pixelData
- Name: <UserType>k__BackingField
Entry: 7
- Data: 11|System.RuntimeType, mscorlib
+ Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Color32[], UnityEngine.CoreModule
@@ -224,7 +230,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
- Data: 11
+ Data: 12
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -239,7 +245,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
- Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -263,13 +269,13 @@ MonoBehaviour:
Data: hasData
- Name: $v
Entry: 7
- Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: hasData
- Name: <UserType>k__BackingField
Entry: 7
- Data: 14|System.RuntimeType, mscorlib
+ Data: 15|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -278,7 +284,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
- Data: 14
+ Data: 15
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -293,7 +299,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
- Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -317,16 +323,16 @@ MonoBehaviour:
Data: readWidth
- Name: $v
Entry: 7
- Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: readWidth
- Name: <UserType>k__BackingField
Entry: 9
- Data: 6
+ Data: 9
- Name: <SystemType>k__BackingField
Entry: 9
- Data: 6
+ Data: 9
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -341,7 +347,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
- Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -365,16 +371,166 @@ MonoBehaviour:
Data: readHeight
- Name: $v
Entry: 7
- Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: readHeight
- Name: <UserType>k__BackingField
Entry: 9
- Data: 6
+ Data: 9
- Name: <SystemType>k__BackingField
Entry: 9
- Data: 6
+ Data: 9
+ - Name: <SyncMode>k__BackingField
+ Entry: 7
+ Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
+ - Name:
+ Entry: 6
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name: <IsSerialized>k__BackingField
+ Entry: 5
+ Data: false
+ - Name: _fieldAttributes
+ Entry: 7
+ Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ - Name:
+ Entry: 12
+ Data: 0
+ - Name:
+ Entry: 13
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 7
+ Data:
+ - Name: $k
+ Entry: 1
+ Data: wallSyncTime
+ - Name: $v
+ Entry: 7
+ Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ - Name: <Name>k__BackingField
+ Entry: 1
+ Data: wallSyncTime
+ - Name: <UserType>k__BackingField
+ Entry: 7
+ Data: 22|System.RuntimeType, mscorlib
+ - Name:
+ Entry: 1
+ Data: System.Single, mscorlib
+ - Name:
+ Entry: 8
+ Data:
+ - Name: <SystemType>k__BackingField
+ Entry: 9
+ Data: 22
+ - Name: <SyncMode>k__BackingField
+ Entry: 7
+ Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
+ - Name:
+ Entry: 6
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name: <IsSerialized>k__BackingField
+ Entry: 5
+ Data: false
+ - Name: _fieldAttributes
+ Entry: 7
+ Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ - Name:
+ Entry: 12
+ Data: 0
+ - Name:
+ Entry: 13
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 7
+ Data:
+ - Name: $k
+ Entry: 1
+ Data: logicalSyncTimeMs
+ - Name: $v
+ Entry: 7
+ Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ - Name: <Name>k__BackingField
+ Entry: 1
+ Data: logicalSyncTimeMs
+ - Name: <UserType>k__BackingField
+ Entry: 9
+ Data: 22
+ - Name: <SystemType>k__BackingField
+ Entry: 9
+ Data: 22
+ - Name: <SyncMode>k__BackingField
+ Entry: 7
+ Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
+ - Name:
+ Entry: 6
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name: <IsSerialized>k__BackingField
+ Entry: 5
+ Data: false
+ - Name: _fieldAttributes
+ Entry: 7
+ Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ - Name:
+ Entry: 12
+ Data: 0
+ - Name:
+ Entry: 13
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 8
+ Data:
+ - Name:
+ Entry: 7
+ Data:
+ - Name: $k
+ Entry: 1
+ Data: logicalTimeFactor
+ - Name: $v
+ Entry: 7
+ Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
+ - Name: <Name>k__BackingField
+ Entry: 1
+ Data: logicalTimeFactor
+ - Name: <UserType>k__BackingField
+ Entry: 9
+ Data: 22
+ - Name: <SystemType>k__BackingField
+ Entry: 9
+ Data: 22
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -389,7 +545,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
- Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
+ Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
diff --git a/Scripts/DataDecoder.cs b/Scripts/DataDecoder.cs
index 96f4a7d..9715d81 100644
--- a/Scripts/DataDecoder.cs
+++ b/Scripts/DataDecoder.cs
@@ -9,7 +9,7 @@ using VRC.Udon.Common.Interfaces;
public class DataDecoder : UdonSharpBehaviour
{
public RenderTexture sourceTexture;
- public int tileToCheck = 0;
+ public MeshRenderer target;
private int tileSize = 8;
// Minimum size (in pixels) of a tile. This is shared with our tixl operator.
@@ -20,6 +20,13 @@ public class DataDecoder : UdonSharpBehaviour
private int readWidth;
private int readHeight;
+ // The wall time at which we last saw a sync event
+ private float wallSyncTime;
+ // The logical time corresponding to the last sync event
+ private float logicalSyncTimeMs;
+ // The rate at which logical time passes every second.
+ private float logicalTimeFactor;
+
// Top-level data types.
private const int kT_TimeSyncData = 0;
@@ -65,6 +72,14 @@ public class DataDecoder : UdonSharpBehaviour
ProcessTiles();
hasData = false;
}
+
+ if (wallSyncTime != null) {
+ float logicalTime = logicalSyncTimeMs * 0.001f +
+ logicalTimeFactor * (Time.time - wallSyncTime);
+ if (target != null) {
+ target.material.SetFloat("_Logical_Time", logicalTime);
+ }
+ }
}
public override void OnAsyncGpuReadbackComplete(VRCAsyncGPUReadbackRequest request)
@@ -146,10 +161,12 @@ public class DataDecoder : UdonSharpBehaviour
int checksumLocal = tileSize + lengthSubpixels;
Color32 parsed_first = GetTileRGB(0);
+ /*
Debug.Log($"First tile: {parsed_first.r} {parsed_first.g} {parsed_first.b}");
Debug.Log($"Parsed size {tileSize}");
Debug.Log($"Parsed length {lengthSubpixels}");
Debug.Log($"Parsed checksum {checksumRemote}");
+ */
// Collect all nibbles into a flat array. Note that these are still
// encoded.
@@ -173,10 +190,10 @@ public class DataDecoder : UdonSharpBehaviour
checksumLocal += (nibbles[i] >> 4) & 0x0F;
}
- Debug.Log($"Local checksum {checksumLocal}");
+ //Debug.Log($"Local checksum {checksumLocal}");
if (checksumLocal != checksumRemote) {
- Debug.LogWarning($"Checksums don't match. Attempting error recovery.");
+ //Debug.LogWarning($"Checksums don't match. Attempting error recovery.");
// Data is submitted in triplicate. Perform a bitwise majority vote
// with `(a & b) | (a & c) | (b & c)`.
@@ -219,8 +236,9 @@ public class DataDecoder : UdonSharpBehaviour
// See DataEncoder.cs. It puts the upper 4 bits before the lower 4 bits.
bytes[i] = (byte) ((nibbles[2*i] & 0xF0) | ((nibbles[2*i+1] & 0xF0) >> 4));
}
- Debug.Log($"Parsed {bytes.Length} bytes from {nibbles.Length} subpixels");
+ //Debug.Log($"Parsed {bytes.Length} bytes from {nibbles.Length} subpixels");
+ // Parse input.
int bOff = 0;
while (HasBytesLeft(bytes, bOff, 8)) {
int type = GetInt(ref bytes, ref bOff);
@@ -232,9 +250,17 @@ public class DataDecoder : UdonSharpBehaviour
switch (type) {
case kT_TimeSyncData:
{
- float lastSyncTimeMs = GetFloat(ref bytes, ref bOff);
- float measureTimeUs = GetFloat(ref bytes, ref bOff);
- Debug.Log($"Parsed time sync data: {lastSyncTimeMs} {measureTimeUs}");
+ float syncTimeMs = GetFloat(ref bytes, ref bOff);
+ float measureTime = GetFloat(ref bytes, ref bOff) * 1e-6f;
+ //Debug.Log($"Parsed time sync data: {syncTimeMs} {measureTimeUs}");
+
+ if (logicalSyncTimeMs != syncTimeMs) {
+ // Indicate that we have seen a sync event.
+ wallSyncTime = Time.time;
+ Debug.Log($"Sync time updated: t0={logicalSyncTimeMs} ms, k=${measureTime}");
+ }
+ logicalSyncTimeMs = syncTimeMs;
+ logicalTimeFactor = 1.0f / measureTime;
break;
}
}
diff --git a/features.cginc b/features.cginc
index cb5a1d7..def13bd 100644
--- a/features.cginc
+++ b/features.cginc
@@ -64,4 +64,8 @@
#pragma shader_feature_local _SHADOW_CASTER
//endex
+//ifex _Logical_Time_Enabled==0
+#pragma shader_feature_local _LOGICAL_TIME
+//endex
+
#endif // __FEATURES_INC
diff --git a/globals.cginc b/globals.cginc
index fd865dc..ed76917 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -5,6 +5,8 @@
SamplerState point_repeat_s;
SamplerState linear_repeat_s;
+SamplerState aniso4_trilinear_repeat_s;
+SamplerState aniso8_trilinear_repeat_s;
SamplerState aniso16_trilinear_repeat_s;
SamplerState bilinear_repeat_s;
SamplerState linear_clamp_s;
@@ -100,4 +102,16 @@ float4 _Center_Offset_Heightmap_ST;
float _Center_Offset_Factor;
#endif // _CENTER_OFFSET
+#if defined(_LOGICAL_TIME)
+float _Logical_Time;
+#endif // _LOGICAL_TIME
+
+float getTime() {
+#if defined(_LOGICAL_TIME)
+ return _Logical_Time;
+#else
+ return _Time[0];
+#endif // _LOGICAL_TIME
+}
+
#endif // __GLOBALS_INC
diff --git a/pbr.cginc b/pbr.cginc
index 104a5d8..7117170 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -54,7 +54,7 @@ Pbr getPbr(v2f i) {
Pbr pbr = (Pbr) 0;
#if defined(_UV_SCROLL)
- i.uv0 += _Time[0] * _UV_Scroll_Speed;
+ i.uv0 += getTime() * _UV_Scroll_Speed;
#endif // _UV_SCROLL
pbr.albedo = _MainTex.Sample(aniso16_trilinear_repeat_s, i.uv0 * _MainTex_ST.xy + _MainTex_ST.zw);
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,