_LightTexture0 flickering in Deferred surface shader (built in renderer - 2020.3.26f1)
I've got a surface shader with the built-in renderer doing a deferred pass. I am trying to get the directional light cookie to control some shadows a bit more, however it tends to flicker and will turn off entirely if I hover over a tooltip in the editor or bring up a color picker. It comes back if my cursor enters the scene or Game view.
I've brought up the frame debugger and notice _LightTexture0, which has the cookie texture, is getting overridden whenever I do those above operations, however this does not happen for forward pass shaders. only deferred.
Also when building it doesn't how up at all. Anyone know what this might be? I've looked around for any system overwriting the _LightTexture0 shader param manually and nothing in my project is doing so. Only thing I can think of is some bug in this version of unity or this is just unsupported in deferred.
In the shader, I have the following.
Tags{ "Queue" = "AlphaTest" "RenderType" = "TransparentCutout" }
LOD 200
#pragma surface surf Booma alphatest:_Cutoff vertex:vert addshadow
#pragma target 4.0
#pragma multi_compile DIRECTIONAL_COOKIE
#include "UnityPBSLighting.cginc"
#include "AutoLight.cginc"
....
inline half4 LightingBooma_Deferred(SurfaceOutputCustom s, half3 viewDir, UnityGI gi, out half4 outDiffuseOcclusion, out half4 outSpecSmoothness, out half4 outNormal)
{
...
#if defined(DIRECTIONAL_COOKIE)
half cookieAtten = 1;
if (0.0 == _WorldSpaceLightPos0.w) // directional light?
{
cookieAtten = tex2D(_LightTexture0, s.lPos.xy).a;
}
c.rgb += cookieAtten * _Illum;
#endif
...
}
Answer by smoore2171 · Apr 23 at 02:57 AM
nvm, I was being a dummy and forgot how deferred shading works evidently. I ended up passing my cookie as a global shader texture and all my shaders just use that instead.