+7
À l'étude

Shader compile is not setting proper UnityGI variable syntax

Manish il y a 9 ans mis à jour par Freya Holmér (Developer) il y a 8 ans 2

We have a shader that has a section under "/////// GI Data:".. inside it has a line

UnityGIInput d;

After using this shader in a scene that has Global Illumination on it, the Unity build will not complete without errors as we get a shader compilation error of "Shader error in '<shaderName>': variable 'd' used without having been completely initialized at line <x> "


Per http://docs.unity3d.com/Manual/UpgradeGuide5-Shaders.html, which says "You need to fully initialize output variables. Use UNITY_INITIALIZE_OUTPUT helper macro, just like you would on D3D11."


So we edited the shader code to be

UnityGIInput d;

UNITY_INITIALIZE_OUTPUT(UnityGIInput, d);


And everything Unity-compiled fine. That is, until we had to modify the shader clicked the "compile" button in shader forge. Doing to removed the "UNITY_INITIALIZE_OUTPUT(UnityGIInput, d);" line every time.


We believe shader forge should always fully init the output variables when it generates shader code.


Any idea how to fix this permanently?


Thanks

À l'étude

I'll get this fixed in the next update!