From eed8c3622c6d1ff7e54fd971bf470c70492e55bb Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 14 Jul 2024 12:23:00 -0700 Subject: Outline bugfixes * Outlines now calculated in object space * Outlines calculated before shearing --- tooner.shader | 2 -- tooner_outline_pass.cginc | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tooner.shader b/tooner.shader index a9f5ca7..3185682 100644 --- a/tooner.shader +++ b/tooner.shader @@ -314,7 +314,6 @@ Shader "yum_food/tooner" #include "tooner_lighting.cginc" ENDCG } - /* Pass { Tags { "RenderType" = "Opaque" @@ -379,7 +378,6 @@ Shader "yum_food/tooner" #include "mochie_shadow_caster.cginc" ENDCG } - */ } CustomEditor "ToonerGUI" } diff --git a/tooner_outline_pass.cginc b/tooner_outline_pass.cginc index 72deee6..fe10c46 100644 --- a/tooner_outline_pass.cginc +++ b/tooner_outline_pass.cginc @@ -41,32 +41,30 @@ v2f vert(appdata v) } #endif + float4 objPos = v.vertex; + +#if defined(_OUTLINES) + float outline_mask = _Outline_Mask.SampleLevel(linear_repeat_s, v.uv0.xy, /*lod=*/1); + outline_mask = _Outline_Mask_Invert > 1E-6 ? 1 - outline_mask : outline_mask; + + objPos.xyz += v.normal * _Outline_Width * outline_mask * _Outline_Width_Multiplier; +#endif + #if !defined(_SCROLL) && defined(_GIMMICK_SHEAR_LOCATION) if (_Gimmick_Shear_Location_Enable_Dynamic) { - v.vertex = mul(float4x4( + objPos = mul(float4x4( _Gimmick_Shear_Location_Strength.x, 0, 0, 0, 0, _Gimmick_Shear_Location_Strength.y, 0, 0, 0, 0, _Gimmick_Shear_Location_Strength.z, 0, 0, 0, 0, _Gimmick_Shear_Location_Strength.w), - v.vertex); + objPos); } #endif - float4 objPos = v.vertex; - float4 clipPos = UnityObjectToClipPos(v.vertex); - float3 clipNormal = mul((float3x3) UNITY_MATRIX_MVP, v.normal); float4 worldPos = mul(unity_ObjectToWorld, objPos); float3 worldNormal = UnityObjectToWorldNormal(v.normal); - -#if defined(_OUTLINES) - float outline_mask = _Outline_Mask.SampleLevel(linear_repeat_s, v.uv0.xy, /*lod=*/1); - outline_mask = _Outline_Mask_Invert > 1E-6 ? 1 - outline_mask : outline_mask; - - worldPos.xyz += worldNormal * _Outline_Width * outline_mask * _Outline_Width_Multiplier; - - objPos = mul(unity_WorldToObject, worldPos); - clipPos = UnityObjectToClipPos(objPos); -#endif + float4 clipPos = UnityObjectToClipPos(objPos); + float3 clipNormal = mul((float3x3) UNITY_MATRIX_MVP, v.normal); v2f o; o.worldPos = worldPos; -- cgit v1.2.3