So I’m trying to build a shader that extends the Standard shader a little bit, adding a simple color overlay. So I wrote this shader:
Shader "EncounterMapLayer" {
Properties {
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_MetallicGlossMap("Metallic", 2D) = "white" {}
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
_ParallaxMap ("Height Map", 2D) = "black" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
_EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
_DetailNormalMapScale("Scale", Float) = 1.0
_DetailNormalMap("Normal Map", 2D) = "bump" {}
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0
// UI-only data
[HideInInspector] _EmissionScaleUI("Scale", Float) = 0.0
[HideInInspector] _EmissionColorUI("Color", Color) = (1,1,1)
// Blending state
[HideInInspector] _Mode ("__mode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
// Extra color map
[HideInInspector] _TileColorMap("Tile Color", 2D) = "white" {}
}
CGINCLUDE
#define UNITY_SETUP_BRDF_INPUT MetallicSetup
ENDCG
SubShader {
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
UsePass "Standard/FORWARD"
UsePass "Standard/FORWARD_DELTA"
UsePass "Standard/ShadowCaster"
UsePass "Standard/DEFERRED"
Pass {
Blend DstColor Zero
SetTexture [_TileColorMap] { combine texture }
}
}
SubShader {
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 150
UsePass "Standard/FORWARD"
UsePass "Standard/FORWARD_DELTA"
UsePass "Standard/ShadowCaster"
Pass {
Blend DstColor Zero
SetTexture [_TileColorMap] { combine texture }
}
}
FallBack "VertexLit"
CustomEditor "StandardShaderGUI"
}
I use the UsePass to avoid duplicating any more of the Standard Shader than I have to. Unfortunately, when I do this, the normal mapping turns off. My best guess as to why is that the “_NORMALMAP” keyword somehow doesn’t propagate through UsePass.
If I copy all of the passes into my shader directly, instead of using UsePass, then the normal mapping starts working again. That’ll work, but I’d rather not do that if I don’t have to.