diff options
| author | yum <yum.food.vr@gmail.com> | 2025-03-29 21:15:57 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-03-29 21:15:57 -0700 |
| commit | 3f1915bbd0e6176e625c484cf24a460cc88bfeac (patch) | |
| tree | d71f97e21e430ce61e1b748ec30ba7cfb3b7d1d1 | |
| parent | 6579d30f558908c23889f9e691a5932a49ecdedd (diff) | |
Add basic audiolink to vertex domain warping
| -rw-r--r-- | 2ner.cginc | 11 | ||||
| -rw-r--r-- | 2ner.shader | 4 | ||||
| -rw-r--r-- | features.cginc | 4 | ||||
| -rw-r--r-- | globals.cginc | 4 | ||||
| -rw-r--r-- | vertex_domain_warping.cginc | 30 |
5 files changed, 38 insertions, 15 deletions
@@ -17,6 +17,7 @@ #include "shatter_wave.cginc"
#include "ssfd.cginc"
#include "tessellation.cginc"
+#include "vertex_domain_warping.cginc"
#include "yum_brdf.cginc"
#include "yum_pbr.cginc"
#include "yum_lighting.cginc"
@@ -80,15 +81,7 @@ v2f vert(appdata v) { #endif
#if defined(_VERTEX_DOMAIN_WARPING)
- float3 basePos = v.vertex.xyz;
- float t = _Time[0] * _Vertex_Domain_Warping_Speed;
- for (uint i = 0; i < _Vertex_Domain_Warping_Octaves; i++) {
- float3 uv = basePos * _Vertex_Domain_Warping_Scale +
- _Time[0] * _Vertex_Domain_Warping_Speed;
- float3 noise = _Vertex_Domain_Warping_Noise.SampleLevel(trilinear_repeat_s, uv, 0);
- basePos += (noise * 2 - 1) * _Vertex_Domain_Warping_Strength;
- }
- v.vertex.xyz = basePos;
+ v.vertex.xyz = domainWarpVertexPosition(v.vertex.xyz);
#endif
#if defined(OUTLINE_PASS)
diff --git a/2ner.shader b/2ner.shader index 00a485f..e43c4f5 100644 --- a/2ner.shader +++ b/2ner.shader @@ -579,6 +579,10 @@ Shader "yum_food/2ner" _Vertex_Domain_Warping_Scale("Scale", Float) = 1.0 _Vertex_Domain_Warping_Octaves("Octaves", Float) = 1.0 _Vertex_Domain_Warping_Speed("Speed", Float) = 1.0 + [HideInInspector] m_start_Vertex_Domain_Warping_Audiolink("Audiolink", Float) = 0 + [ThryToggle(_VERTEX_DOMAIN_WARPING_AUDIOLINK)] _Vertex_Domain_Warping_Audiolink_Enabled("Enable", Float) = 0 + _Vertex_Domain_Warping_Audiolink_VU_Factors("VU factors (strength|scale|unused|unused)", Vector) = (1, 1, 0, 0) + [HideInInspector] m_end_Vertex_Domain_Warping_Audiolink("Audiolink", Float) = 0 [HideInInspector] m_end_Vertex_Domain_Warping("Vertex domain warping", Float) = 0 //endex diff --git a/features.cginc b/features.cginc index a74b4f7..b753f31 100644 --- a/features.cginc +++ b/features.cginc @@ -152,6 +152,10 @@ #pragma shader_feature_local _VERTEX_DOMAIN_WARPING //endex +//ifex _Vertex_Domain_Warping_Audiolink_Enabled==0 +#pragma shader_feature_local _VERTEX_DOMAIN_WARPING_AUDIOLINK +//endex + //ifex _UV_Domain_Warping_Enabled==0 #pragma shader_feature_local _UV_DOMAIN_WARPING //endex diff --git a/globals.cginc b/globals.cginc index 74aa9ea..2578e3a 100644 --- a/globals.cginc +++ b/globals.cginc @@ -294,6 +294,10 @@ float _Vertex_Domain_Warping_Octaves; float _Vertex_Domain_Warping_Speed;
#endif // _VERTEX_DOMAIN_WARPING
+#if defined(_VERTEX_DOMAIN_WARPING_AUDIOLINK)
+float4 _Vertex_Domain_Warping_Audiolink_VU_Factors;
+#endif // _VERTEX_DOMAIN_WARPING_AUDIOLINK
+
#if defined(_UV_DOMAIN_WARPING)
float _UV_Domain_Warping_Spatial_Strength;
float _UV_Domain_Warping_Spatial_Scale;
diff --git a/vertex_domain_warping.cginc b/vertex_domain_warping.cginc index 0eea172..3bbc5cd 100644 --- a/vertex_domain_warping.cginc +++ b/vertex_domain_warping.cginc @@ -1,15 +1,33 @@ #ifndef __VERTEX_DOMAIN_WARPING_INC
#define __VERTEX_DOMAIN_WARPING_INC
+#include "audiolink.cginc"
+#include "globals.cginc"
#include "math.cginc"
-float3 domainWarpVertexPosition(float3 vertex, float3 normal, float3 tangent,
- float3 binormal, float3 worldPos, float3 centerCamPos) {
- float3 worldNormal = UnityObjectToWorldNormal(normal);
- float3 worldTangent = UnityObjectToWorldDir(tangent);
- float3 worldBinormal = cross(worldNormal, worldTangent) * tangent.w * unity_WorldTransformParams.w;
+float3 domainWarpVertexPosition(float3 objPos) {
+#if defined(_VERTEX_DOMAIN_WARPING)
+ float speed = _Vertex_Domain_Warping_Speed;
+ float scale = _Vertex_Domain_Warping_Scale;
+ float strength = _Vertex_Domain_Warping_Strength;
+ float octaves = _Vertex_Domain_Warping_Octaves;
- float3 worldPos = mul(unity_ObjectToWorld, vertex);
+#if defined(_VERTEX_DOMAIN_WARPING_AUDIOLINK)
+ [branch]
+ if (AudioLinkIsAvailable()) {
+ float vu = AudioLinkData(ALPASS_FILTEREDVU_INTENSITY + uint2(0, 0));
+ strength += vu * _Vertex_Domain_Warping_Audiolink_VU_Factors.x;
+ scale += vu * _Vertex_Domain_Warping_Audiolink_VU_Factors.y;
+ }
+#endif
+
+ for (uint i = 0; i < octaves; i++) {
+ float3 uv = objPos * scale + speed * _Time[0];
+ float3 noise = _Vertex_Domain_Warping_Noise.SampleLevel(trilinear_repeat_s, uv, 0);
+ objPos += (noise * 2 - 1) * strength;
+ }
+#endif // _VERTEX_DOMAIN_WARPING
+ return objPos;
}
#endif // __VERTEX_DOMAIN_WARPING_INC
|
