diff --git a/Assets/Shaders/DecalsLighting.cginc b/Assets/Shaders/DecalsLighting.cginc index 3d5bcae..3105d94 100644 --- a/Assets/Shaders/DecalsLighting.cginc +++ b/Assets/Shaders/DecalsLighting.cginc @@ -61,7 +61,7 @@ inline half4 KSPLightingStandardSpecular_Deferred (SurfaceOutputStandardSpecular outEmission = half4(s.Emission, s.Alpha); #ifndef UNITY_HDR_ON - outEmission.rgb = exp2(-outEmission.rgb); + outEmission.rgb = saturate(exp2(-outEmission.rgb)); #endif return outEmission; diff --git a/Assets/Shaders/DecalsSurface.cginc b/Assets/Shaders/DecalsSurface.cginc index ab31063..a20bc98 100644 --- a/Assets/Shaders/DecalsSurface.cginc +++ b/Assets/Shaders/DecalsSurface.cginc @@ -228,7 +228,12 @@ void frag_deferred (v2f IN, o.Normal = WorldNormal; #endif + #ifdef DECAL_PREVIEW + o.Alpha = 1; + #endif + KSPLightingStandardSpecular_Deferred(o, outGBuffer0, outGBuffer1, outGBuffer2, outEmission); + outGBuffer0.a = o.Alpha; outGBuffer1 *= o.Alpha; outGBuffer2.a = o.Alpha; diff --git a/Assets/Shaders/StandardDecal.cginc b/Assets/Shaders/StandardDecal.cginc index 71a537a..aed5f13 100644 --- a/Assets/Shaders/StandardDecal.cginc +++ b/Assets/Shaders/StandardDecal.cginc @@ -18,7 +18,7 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutputStandardSpecular o) { #ifdef DECAL_SPECMAP float4 specular = tex2D(_SpecMap, IN.uv_specmap); - o.Specular = specular + o.Specular = specular; #endif o.Smoothness = _Shininess; diff --git a/Assets/Shaders/StandardDecal.shader b/Assets/Shaders/StandardDecal.shader index 970a677..9aadb1c 100644 --- a/Assets/Shaders/StandardDecal.shader +++ b/Assets/Shaders/StandardDecal.shader @@ -119,12 +119,7 @@ #pragma fragment frag_deferred_prepass #pragma target 3.0 - #pragma multi_compile_deferred nolightmap nodirlightmap nodynlightmap - #pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE #pragma multi_compile_local __ DECAL_PREVIEW - // #pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP - #pragma multi_compile_local __ DECAL_SPECMAP - // #pragma multi_compile_local __ DECAL_EMISSIVE #pragma multi_compile_local __ DECAL_SDF_ALPHA #include "UnityCG.cginc" @@ -140,21 +135,26 @@ { Name "DEFERRED" Tags { "LightMode" = "Deferred" } - ZWrite [_ZWrite] + ZWrite On ZTest LEqual Offset -1, -1 - Blend 0 SrcAlpha OneMinusSrcAlpha, Zero One + Blend 0 SrcAlpha OneMinusSrcAlpha, One One Blend 1 One One Blend 2 SrcAlpha OneMinusSrcAlpha, Zero One Blend 3 SrcAlpha OneMinusSrcAlpha, Zero One + Stencil { + Ref 8 + Comp Always + Pass Replace + } + CGPROGRAM #pragma vertex vert #pragma fragment frag_deferred #pragma target 3.0 - #pragma multi_compile_deferred nolightmap nodirlightmap nodynlightmap - #pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE + #pragma multi_compile __ UNITY_HDR_ON #pragma multi_compile_local __ DECAL_PREVIEW #pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP #pragma multi_compile_local __ DECAL_SPECMAP @@ -169,5 +169,7 @@ ENDCG } + + UsePass "Legacy Shaders/VertexLit/SHADOWCASTER" } } \ No newline at end of file diff --git a/Assets/Shaders/TextDecal.shader b/Assets/Shaders/TextDecal.shader index 1105436..8ead977 100644 --- a/Assets/Shaders/TextDecal.shader +++ b/Assets/Shaders/TextDecal.shader @@ -120,12 +120,7 @@ #pragma fragment frag_deferred_prepass #pragma target 3.0 - #pragma multi_compile_deferred nolightmap nodirlightmap nodynlightmap - #pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE #pragma multi_compile_local __ DECAL_PREVIEW - // #pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP - #pragma multi_compile_local __ DECAL_SPECMAP - // #pragma multi_compile_local __ DECAL_EMISSIVE #pragma multi_compile_local __ DECAL_SDF_ALPHA #include "UnityCG.cginc" @@ -149,13 +144,18 @@ Blend 2 SrcAlpha OneMinusSrcAlpha, Zero One Blend 3 SrcAlpha OneMinusSrcAlpha, Zero One + Stencil { + Ref 8 + Comp Always + Pass Replace + } + CGPROGRAM #pragma vertex vert #pragma fragment frag_deferred #pragma target 3.0 - #pragma multi_compile_deferred nolightmap nodirlightmap nodynlightmap - #pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE + #pragma multi_compile __ UNITY_HDR_ON #pragma multi_compile_local __ DECAL_PREVIEW #pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP #pragma multi_compile_local __ DECAL_SPECMAP diff --git a/GameData/ConformalDecals/Resources/conformaldecals.shab b/GameData/ConformalDecals/Resources/conformaldecals.shab index 45e8579..8922712 100644 Binary files a/GameData/ConformalDecals/Resources/conformaldecals.shab and b/GameData/ConformalDecals/Resources/conformaldecals.shab differ diff --git a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs index 72a7bc3..c7923ef 100644 --- a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs +++ b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs @@ -45,6 +45,7 @@ public Material DecalMaterial { _decalMaterial.SetInt(DecalPropertyIDs._Cull, (int) CullMode.Off); _decalMaterial.SetInt(DecalPropertyIDs._ZWrite, 0); _decalMaterial.renderQueue = RenderQueue; + _decalMaterial.SetShaderPassEnabled("SHADOWCASTER", false); } return _decalMaterial; @@ -59,6 +60,7 @@ public Material PreviewMaterial { _previewMaterial.EnableKeyword("DECAL_PREVIEW"); _previewMaterial.SetInt(DecalPropertyIDs._Cull, (int) CullMode.Back); _previewMaterial.SetInt(DecalPropertyIDs._ZWrite, 1); + _previewMaterial.SetShaderPassEnabled("DEFERRED_PREPASS", false); } return _previewMaterial;