summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-07-30 20:21:51 -0700
committeryum <yum.food.vr@gmail.com>2025-07-30 20:21:51 -0700
commit5172e2eb9216b876b5b2719fad64b83e0d3a2a9f (patch)
treea900fc7e303cd2dd136a898b1dfa87c97c1f06b3
parentbe4c8a8ee8eaf892d008835225dfd897d259d793 (diff)
consolidate XZ displacement normal math
-rw-r--r--2ner.shader3
-rw-r--r--globals.cginc6
-rw-r--r--yum_pbr.cginc7
3 files changed, 6 insertions, 10 deletions
diff --git a/2ner.shader b/2ner.shader
index 87cab4b..d395abf 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -965,8 +965,7 @@ Shader "yum_food/2ner"
//ifex _Gradient_Normals_0_Horizontal_Enabled==0
[HideInInspector] m_start_Gradient_Normals_0_Horizontal("Horizontal displacement gradient", Float) = 0
[ThryToggle(_GRADIENT_NORMALS_0_HORIZONTAL)] _Gradient_Normals_0_Horizontal_Enabled("Enable", Float) = 0
- _Gradient_Normals_0_X("(dfx/dx, dfx/dz)", 2D) = "black" {}
- _Gradient_Normals_0_Z("(dfz/dx, dfz/dz)", 2D) = "black" {}
+ _Gradient_Normals_0_Horizontal("(dfx/dx, dfz/dz)", 2D) = "black" {}
[HideInInspector] m_end_Gradient_Normals_0_Horizontal("Horizontal displacement gradient", Float) = 0
//endex
diff --git a/globals.cginc b/globals.cginc
index 74857e6..65dea1b 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -338,10 +338,8 @@ texture2D _Gradient_Normals_0_Vertical;
float4 _Gradient_Normals_0_Vertical_ST;
#endif
#if defined(_GRADIENT_NORMALS_0_HORIZONTAL)
-texture2D _Gradient_Normals_0_X;
-float4 _Gradient_Normals_0_X_ST;
-texture2D _Gradient_Normals_0_Z;
-float4 _Gradient_Normals_0_Z_ST;
+texture2D _Gradient_Normals_0_Horizontal;
+float4 _Gradient_Normals_0_Horizontal_ST;
#endif
#if defined(_VERTEX_DOMAIN_WARPING)
diff --git a/yum_pbr.cginc b/yum_pbr.cginc
index 08bc8e2..cbcac8f 100644
--- a/yum_pbr.cginc
+++ b/yum_pbr.cginc
@@ -29,11 +29,10 @@ void applyGradientNormals(v2f i, inout YumPbr pbr) {
float2 g0_dfy = _Gradient_Normals_0_Vertical.SampleLevel(bilinear_repeat_s, g0_uv, 0).rg;
float2 g0 = g0_dfy;
#if defined(_GRADIENT_NORMALS_0_HORIZONTAL)
- float2 g0_dfx = _Gradient_Normals_0_X.SampleLevel(bilinear_repeat_s, g0_uv, 0).rg;
- float2 g0_dfz = _Gradient_Normals_0_Z.SampleLevel(bilinear_repeat_s, g0_uv, 0).rg;
+ float2 g0_dfxz = _Gradient_Normals_0_Horizontal.SampleLevel(bilinear_repeat_s, g0_uv, 0).rg;
g0 = float2(
- g0_dfy[0] / (1 + g0_dfx[0]),
- g0_dfy[1] / (1 + g0_dfz[1])
+ g0_dfy[0] / (1 + g0_dfxz[0]),
+ g0_dfy[1] / (1 + g0_dfxz[1])
);
#endif // _GRADIENT_NORMALS_0_HORIZONTAL
gradient += g0;