diff options
| author | yum <yum.food.vr@gmail.com> | 2024-07-14 12:23:00 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-07-14 12:23:00 -0700 |
| commit | eed8c3622c6d1ff7e54fd971bf470c70492e55bb (patch) | |
| tree | 7aec033054ee414ec5da2c74ebe7dadbd4084ae9 | |
| parent | 3dcb2fd0e240f3c0141e65c32bc2c4a7f8e9fd20 (diff) | |
Outline bugfixes
* Outlines now calculated in object space
* Outlines calculated before shearing
| -rw-r--r-- | tooner.shader | 2 | ||||
| -rw-r--r-- | 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; |
