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 usingShader "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?