I have a custom shader that uses the Unity GI template as a base and am trying to use an emissive map that has multiple colors. When I use this emissive map for a standard shader, it works properly and as expected by having colored emissive where the circles are. However, when using a custom shader that only adds an emissive to the Unity GI base shader, the entire object turns white. Here is the current code I am using Code (CSharp): Shader "Custom/TestShader" { Properties{ _MainTex("Albedo (RGB)", 2D) = "white" {} [HDR]_EmissionColor("Color", Color) = (0,0,0) _EmissionMap("Emission", 2D) = "white" {} } SubShader{ Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf StandardDefaultGI #include "UnityPBSLighting.cginc" sampler2D _MainTex; inline half4 LightingStandardDefaultGI(SurfaceOutputStandard s, half3 viewDir, UnityGI gi) { return LightingStandard(s, viewDir, gi); } inline void LightingStandardDefaultGI_GI( SurfaceOutputStandard s, UnityGIInput data, inout UnityGI gi) { LightingStandard_GI(s, data, gi); } fixed4 _EmissionColor; sampler2D _EmissionMap; struct Input { float2 uv_MainTex; }; void surf(Input IN, inout SurfaceOutputStandard o) { o.Albedo = tex2D(_MainTex, IN.uv_MainTex); o.Emission = tex2D(_EmissionMap, IN.uv_MainTex).a *_EmissionColor; } ENDCG } FallBack "Diffuse" } The left image is the current shader I have attached and the right is a standard shader with the emissive map. Whenever I use any other emissive maps, the current shader is fine. See below: How should I properly incorporate the emissive into the Unity templated GI shader to properly use my emssive map?
Here is the solution I came up with to get Emission working with GI. Code (csharp): Shader "Custom/TestShader" { Properties{ _MainTex("Albedo (RGB)", 2D) = "white" {} [HDR]_EmissionColor("Color", Color) = (0,0,0) _EmissionMap("Emission", 2D) = "white" {} _Color ("Color", Color) = (1,1,1,1) } SubShader{ Pass { Name "META" Tags {"LightMode"="Meta"} Cull Off CGPROGRAM #include"UnityStandardMeta.cginc" sampler2D _GIAlbedoTex; fixed4 _GIAlbedoColor; float4 frag_meta2 (v2f_meta i): SV_Target { FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv); UnityMetaInput o; UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o); fixed4 c = tex2D (_GIAlbedoTex, i.uv); o.Albedo = fixed3(c.rgb * _GIAlbedoColor.rgb); o.Emission = tex2D(_EmissionMap, i.uv) * _EmissionColor; return UnityMetaFragment(o); } #pragma vertex vert_meta #pragma fragment frag_meta2 #pragma shader_feature _EMISSION #pragma shader_feature _METALLICGLOSSMAP #pragma shader_feature ___ _DETAIL_MULX2 ENDCG } Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf StandardDefaultGI #include "UnityPBSLighting.cginc" sampler2D _MainTex; sampler2D _EmissionMap; fixed4 _EmissionColor; inline half4 LightingStandardDefaultGI(SurfaceOutputStandard s, half3 viewDir, UnityGI gi) { return LightingStandard(s, viewDir, gi); } inline void LightingStandardDefaultGI_GI( SurfaceOutputStandard s, UnityGIInput data, inout UnityGI gi) { LightingStandard_GI(s, data, gi); } fixed4 _Color; struct Input { float2 uv_MainTex; }; void surf(Input IN, inout SurfaceOutputStandard o) { half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Alpha = c.a; o.Emission = tex2D(_EmissionMap, IN.uv_MainTex) * _EmissionColor; } ENDCG } FallBack "Diffuse" } [/code