From 6e07433eed7ed31d8154ca5de3870a001e66fa3d Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 31 May 2020 18:25:29 -0700 Subject: [PATCH] Fix ForwardAdd overlap in shader This requires some code change to actually work (the material Queue also needs to be updated dynamically) --- Assets/Shaders/DecalFeatureBumped.shader | 14 ++++++++------ .../ConformalDecals/Resources/conformaldecals.shab | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Assets/Shaders/DecalFeatureBumped.shader b/Assets/Shaders/DecalFeatureBumped.shader index 3d66fbe..18c8788 100644 --- a/Assets/Shaders/DecalFeatureBumped.shader +++ b/Assets/Shaders/DecalFeatureBumped.shader @@ -17,17 +17,16 @@ Shader "ConformalDecals/Feature/Bumped" } SubShader { - Tags { "Queue" = "Geometry+400" } - ZWrite On + Tags { "Queue" = "Geometry+100" } Cull Off - ZTest LEqual - Offset -1, -1 Pass { Name "FORWARD" Tags { "LightMode" = "ForwardBase" } Blend SrcAlpha OneMinusSrcAlpha + ZWrite Off + ZTest LEqual CGPROGRAM #pragma vertex vert_forward @@ -60,7 +59,7 @@ Shader "ConformalDecals/Feature/Bumped" float3 normal = UnpackNormal(tex2D(_BumpMap, IN.uv_bump)); // clip alpha - clip(color.a - _Cutoff); + clip(color.a - saturate(_Cutoff + 0.01)); half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal)); float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a; @@ -79,6 +78,9 @@ Shader "ConformalDecals/Feature/Bumped" Name "FORWARD" Tags { "LightMode" = "ForwardAdd" } Blend One One + ZWrite On + ZTest Less + Offset -1, -1 CGPROGRAM #pragma vertex vert_forward @@ -111,7 +113,7 @@ Shader "ConformalDecals/Feature/Bumped" float3 normal = UnpackNormal(tex2D(_BumpMap, IN.uv_bump)); // clip alpha - clip(color.a - _Cutoff); + clip(color.a - saturate(_Cutoff + 0.01)); half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal)); float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a; diff --git a/Distribution/GameData/ConformalDecals/Resources/conformaldecals.shab b/Distribution/GameData/ConformalDecals/Resources/conformaldecals.shab index db1c7d2..58d495a 100644 --- a/Distribution/GameData/ConformalDecals/Resources/conformaldecals.shab +++ b/Distribution/GameData/ConformalDecals/Resources/conformaldecals.shab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5c6eac6b56d72887c678fd14aa4f5596e2e3c1ba0da2dcf0e8d9c84789bb5f0 -size 98741 +oid sha256:d1ffb743f95c6917c013dcd9cfd2205c769c2aa550191f17f43cb373b1bec195 +size 98979