diff --git a/.gitignore b/.gitignore index 65b3d63..ed40554 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,9 @@ ExportedObj/ *.opendb *.VC.db +# Autogenerated shaders +Assets/Shaders/Generated/*.shader + # Binaries and support files Source/ConformalDecals/dlls Source/ConformalDecals/bin diff --git a/Assets/Shaders/StandardDecal.cginc b/Assets/Shaders/Generated/StandardDecal.cginc similarity index 95% rename from Assets/Shaders/StandardDecal.cginc rename to Assets/Shaders/Generated/StandardDecal.cginc index 07945bd..f8c2e63 100644 --- a/Assets/Shaders/StandardDecal.cginc +++ b/Assets/Shaders/Generated/StandardDecal.cginc @@ -1,5 +1,5 @@ -#include "DecalsCommon.cginc" -#include "SDF.cginc" +#include "../DecalsCommon.cginc" +#include "../SDF.cginc" void surf(DecalSurfaceInput IN, inout SurfaceOutput o) { float4 color = tex2D(_Decal, IN.uv_decal); diff --git a/Assets/Shaders/StandardDecal.shader b/Assets/Shaders/Generated/StandardDecal.shader.template similarity index 86% rename from Assets/Shaders/StandardDecal.shader rename to Assets/Shaders/Generated/StandardDecal.shader.template index a4aef17..64950c2 100644 --- a/Assets/Shaders/StandardDecal.shader +++ b/Assets/Shaders/Generated/StandardDecal.shader.template @@ -1,12 +1,13 @@ -Shader "ConformalDecals/Decal/Standard" +Shader "{% block shader_name %}ConformalDecals/Decal/Standard{% endblock %}" { Properties { + // Shader-specific properties + //{% block properties %} [Header(Decal)] _Decal("Decal Texture", 2D) = "gray" {} [Toggle(DECAL_SDF_ALPHA)] _Decal_SDF_Alpha ("SDF in Alpha", int) = 0 - [Header(Normal)] [Toggle(DECAL_BASE_NORMAL)] _BaseNormal ("Use Base Normal", int) = 0 [Toggle(DECAL_BUMPMAP)] _Decal_BumpMap ("Has BumpMap", int) = 0 @@ -24,7 +25,9 @@ [Toggle(DECAL_EMISSIVE)] _Decal_Emissive ("Has Emissive", int) = 0 _Emissive("_Emissive", 2D) = "black" {} _EmissiveColor("_EmissiveColor", Color) = (0,0,0,1) + //{% endblock %} + // Common decal properties _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 _DecalOpacity("Opacity", Range(0,1) ) = 1 _Background("Background Color", Color) = (0.9,0.9,0.9,0.7) @@ -67,11 +70,16 @@ #pragma multi_compile DIRECTIONAL #pragma multi_compile_local __ DECAL_PREVIEW #pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP + //{% block pragmas %} #pragma multi_compile_local __ DECAL_SPECMAP #pragma multi_compile_local __ DECAL_EMISSIVE #pragma multi_compile_local __ DECAL_SDF_ALPHA + //{% endblock %} + //{% block body %} #include "StandardDecal.cginc" + //{% endblock %} + ENDCG } @@ -94,11 +102,9 @@ #pragma multi_compile DIRECTIONAL SPOT POINT #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 + //{{ self.pragmas() }} - #include "StandardDecal.cginc" + //{{ self.body() }} ENDCG } @@ -114,6 +120,13 @@ Offset -1, -1 Blend 1 Zero OneMinusSrcColor, Zero OneMinusSrcAlpha + Stencil + { + Ref 1 + Comp Equal + Pass Keep + } + CGPROGRAM #pragma vertex vert #pragma fragment frag_deferred_prepass @@ -121,11 +134,11 @@ #pragma multi_compile_local __ DECAL_PREVIEW #pragma multi_compile_local __ DECAL_BASE_NORMAL - #pragma multi_compile_local __ DECAL_SDF_ALPHA + //{{ self.pragmas() }} #define DECAL_PREPASS - #include "StandardDecal.cginc" + //{{ self.body() }} ENDCG } @@ -147,8 +160,8 @@ Stencil { Ref 1 - Comp Always - Pass Replace + Comp Equal + Pass Keep } CGPROGRAM @@ -159,11 +172,9 @@ #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 - #pragma multi_compile_local __ DECAL_EMISSIVE - #pragma multi_compile_local __ DECAL_SDF_ALPHA + //{{ self.pragmas() }} - #include "StandardDecal.cginc" + //{{ self.body() }} ENDCG } } diff --git a/GameData/ConformalDecals/Resources/conformaldecals.shab b/GameData/ConformalDecals/Resources/conformaldecals.shab index 1398e43..9f7e76d 100644 Binary files a/GameData/ConformalDecals/Resources/conformaldecals.shab and b/GameData/ConformalDecals/Resources/conformaldecals.shab differ