From e8f64516cfd27bb0b6ec1bb866909300185a7507 Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 3 Dec 2025 15:38:16 -0800 Subject: simplify tessellation heightmap direction control logic --- globals.cginc | 4 ++-- tessellation.cginc | 12 ++++++------ 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 -- cgit v1.2.3