I have a custom surface shader which emits light using realtime global illumination in 2021.1 with the standard render pipeline. In the editor everything looks correct and the emitted light bounces on to nearby surfaces, however in my built scene there is no bounced light. I have another material using the standard shader which does properly emit light, so the Enlighten system is working in the scene, just not for my shader. Here is a simplified version of my shader with the logic removed for clarity.
Shader "Custom/GlowShader"
{
Properties
{
[HDR] _EmissionColor ("Emission Color", Color) = (1,1,1,1)
[MaterialToggle] _UseEmission ("Use Emission", float) = 1
[MainTexture] _EmissionMap ("Base (RGB) Trans (A)", 2D) = "white" {}
_AlphaMap ("Alpha Map", 2D) = "white" {}
_LengthCutoff ("Length Cutoff", Range(0.0, 1.0)) = .97
_Smoothing ("Smoothing", Range(0.1, 15.0)) = 3
_Transparency ("Transparency", Range(0.0, 1.0)) = .2
_NoiseTex ("Noise Texture", 2D) = "white" {}
_NoiseStrength ("Noise Strength", Range(0.0, 1.0)) = .1
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "ForceNoShadowCasting"="True"}
LOD 100
ZWrite Off
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard noshadow noambient alpha:fade
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
struct Input
{
float2 uv_MainTex : TEXCOORD0;
float2 uv2_AlphaMap : TEXCOORD1;
};
sampler2D _EmissionMap;
sampler2D _NoiseTex;
sampler2D _AlphaMap;
float4 _EmissionColor;
float _NoiseStrength;
float _LengthCutoff;
float _Smoothing;
float _Transparency;
float _UseEmission;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
float4 col = tex2D (_EmissionMap, IN.uv_MainTex);
float alpha = 1.0;
// logic to calculate alpha and emission based on input textures and values
// ...
// ...
// set output
o.Alpha = alpha;
o.Emission = col.rgb * _EmissionColor * alpha * _UseEmission;
o.Albedo = col.rgb;
o.Metallic = 0.0;
o.Smoothness = 0.0;
}
ENDCG
}
FallBack "Unlit/Transparent"
}
Does anyone have any suggestions. Is there something about the way this shader is compiled that makes it work in editor but not in build? Thank you!