- Home /
Shader errors in Windows build ( renders black ) but not in Editor
We're currently using some shaders created with Shader Forge for our project.
Everything appears to work just fine when playing in the editor, but when we make a build, most of the shaders fail and a lot of black is the result.
During building this error is reported for many of the shaders:
Shader error in 'Shader Forge/shaderName': variable 'd' used without having been completely initialized at line 117 (on d3d11)
This alludes to the following line of shader code:
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
and in the output_log from the build as it's executed:
WARNING: Shader Unsupported: 'Shader Forge/shaderName' - Pass 'FORWARD' has no fragment shader WARNING: Shader Unsupported: 'Shader Forge/shaderName' - Pass 'FORWARD_DELTA' has no vertex shader WARNING: Shader Unsupported: 'Shader Forge/shaderName' - All passes removed
Here is the shader code which documents the lifetime of that crazy 'd' variable up until its moment of shame:
/////// GI Data:
UnityLight light;
#ifdef LIGHTMAP_OFF
light.color = lightColor;
light.dir = lightDirection;
light.ndotl = LambertTerm (normalDirection, light.dir);
#else
light.color = half3(0.f, 0.f, 0.f);
light.ndotl = 0.0f;
light.dir = half3(0.f, 0.f, 0.f);
#endif
UnityGIInput d;
d.light = light;
d.worldPos = i.posWorld.xyz;
d.worldViewDir = viewDirection;
d.atten = attenuation;
d.boxMax[0] = unity_SpecCube0_BoxMax;
d.boxMin[0] = unity_SpecCube0_BoxMin;
d.probePosition[0] = unity_SpecCube0_ProbePosition;
d.probeHDR[0] = unity_SpecCube0_HDR;
d.boxMax[1] = unity_SpecCube1_BoxMax;
d.boxMin[1] = unity_SpecCube1_BoxMin;
d.probePosition[1] = unity_SpecCube1_ProbePosition;
d.probeHDR[1] = unity_SpecCube1_HDR;
Unity_GlossyEnvironmentData ugls_en_data;
ugls_en_data.roughness = 1.0 - gloss;
ugls_en_data.reflUVW = viewReflectDirection;
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
lightDirection = gi.light.dir;
lightColor = gi.light.color;
Is anyone able to suggest a place to start digging which will may unearth the root of the issue we're experiencing here?
Windows Version 8.1 Unity Version 5.3.1f1 Personal Shaderforge Version 1.2.6 Video Card Geforce GTX 980 TI
Many thanks as always.
Just to add that enabling GI in the Scene Lighting Panel makes the runtime issues go away and also the runtime errors in the output_log file are no longer present, but the errors in the Console window after building remain.
The slight problem that I have with this is that while this sort of fixes the visual problems at runtime, I don't really want or need GI enabled and I've really not learned anything from the experience in any meaningful way. :(
Answer by SylvainBellangerOcelotSociety · Jun 10, 2016 at 02:56 PM
Hi Rob, our team is actually facing the exact same issue. Everything seems okay until we try to build the project. The same error and warning pop-up. Sometime some materials seem to crash randomly and compiling the shader once again in shaderforge fix most of the problems (at least in the editor...). Do you guys have any clue or update on how to fix this? Also our project is rendered in deferred and some of our opacity based shaders need to be set to forward. I don't know if it could have a negative impact. Hope you already had some answer to your problems.
Thanks :)
Your answer
Follow this Question
Related Questions
Prevent material from rendering behind itself 0 Answers
How to fix Material with custom shader turning Black in Playmode (Light Weight Render Pipeline) 0 Answers
How can I have a transparent ring around a transparent planet? 0 Answers
Every shader and quality is pink. URP 2 Answers
Custom Shader with Canvas Renderer limit draw calls. 0 Answers