summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-12-03 15:38:16 -0800
committeryum <yum.food.vr@gmail.com>2025-12-03 15:38:16 -0800
commite8f64516cfd27bb0b6ec1bb866909300185a7507 (patch)
tree814a3720c5c659cdba1143f45c048dbc0ed777f8
parent5ffb79e9f39c1e027155200e72b7678ea111273d (diff)
simplify tessellation heightmap direction control logic
-rw-r--r--globals.cginc4
-rw-r--r--tessellation.cginc12
2 files changed, 8 insertions, 8 deletions
diff --git a/globals.cginc b/globals.cginc
index 44d10d5..78f34cd 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -640,9 +640,9 @@ float _Tessellation_Heightmap_7_Scale;
float _Tessellation_Heightmap_7_Offset;
#endif // _TESSELLATION_HEIGHTMAP_7
-#if defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
+// #if defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
float3 _Tessellation_Heightmap_Direction_Control_Vector;
-#endif // _TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL
+// #endif // _TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL
#if defined(_TESSELLATION_RANGE_FACTOR)
float _Tessellation_Range_Factor_Distance_Near;
diff --git a/tessellation.cginc b/tessellation.cginc
index 168bae5..fdfc3b2 100644
--- a/tessellation.cginc
+++ b/tessellation.cginc
@@ -75,12 +75,12 @@ float4 applyHeightmap(float4 objPos, float2 uv, float3 normal, float3 tangent, f
#if defined(_TESSELLATION_HEIGHTMAP_WORLD_SPACE)
objPos.xyz += mul(unity_WorldToObject, height).xyz;
#else
-#if defined(OUTLINE_PASS) && defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
- float3 heightmap_direction = mul(transpose(-float3x3(normal, tangent, binormal)), _Tessellation_Heightmap_Direction_Control_Vector);
-#elif defined(OUTLINE_PASS) && !defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
- float3 heightmap_direction = -normal;
-#elif !defined(OUTLINE_PASS) && defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
- float3 heightmap_direction = mul(transpose(float3x3(normal, tangent, binormal)), _Tessellation_Heightmap_Direction_Control_Vector);
+#if defined(_TESSELLATION_HEIGHTMAP_DIRECTION_CONTROL)
+ float3 heightmap_direction = normalize(
+ normalize(normal) * _Tessellation_Heightmap_Direction_Control_Vector.x +
+ normalize(tangent) * _Tessellation_Heightmap_Direction_Control_Vector.y +
+ normalize(binormal) * _Tessellation_Heightmap_Direction_Control_Vector.z
+ );
#else
float3 heightmap_direction = normal;
#endif