Scene fade in/out script error in 4.5

I have a scene fade in / out script that I’ve used since 4.0 and has been working fine. But since 4.5 it has stopped working.

If simply draws a quad over the scene which gradually fades:
public static void DrawQuad(Material aMaterial, Color aColor, float aAlpha)
{
aColor.a = aAlpha;
aMaterial.SetPass(0);
GL.Color(aColor);
GL.PushMatrix();
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.Vertex3(0, 0, -1);
GL.Vertex3(0, 1, -1);
GL.Vertex3(1, 1, -1);
GL.Vertex3(1, 0, -1);
GL.End();
GL.PopMatrix();
}

With a simple custom material :
fadeMaterial = new Material(“Shader "Plane/No zTest" {” +
“SubShader { Pass { " +
" Blend SrcAlpha OneMinusSrcAlpha " +
" ZWrite Off Cull Off Fog { Mode Off } " +
" BindChannels {” +
" Bind "color", color }" +
“} } }”);

No idea why but since the 4.5 upgrade this script no longer fades, just drops to black for the entire length of the transition.

Script can be found here : http://bit.ly/1kCkJ8L

Had a quick look at this. Looks dx11 related, since turning off dx11 in the player settings fixes the issue. I’ve dropped a note to our graphics team to see if they have any further info and I’ll let you know what they come back with.

I think what happens, is that calling things like GL.Color outside of GL.Begin/End is technically “undefined”. It happens to work on some platforms, but does not work on others (e.g. DX11).

2 Likes

Just as well the docs say this, then. :wink:

This function can only be called between GL.Begin and GL.End functions.

1 Like

Ok, I’ll try updating the shader portion of the code to move those segments within the begin and end block. Thanks.

Just odd that this was working perfectly fine prior to 4.5

That fixed it, thanks for all the help.

Guess there must have been either a tweak workaround before 4.5 or as stated, the update to dx 11 made this invalid.

Anyway working now, thanks again.

And so begins the proverbial face slap moment :smile: RTFM.

Although I’m still a noob to shaders, learning more each day.

Hmm. Seems not all the docs agree. Since this is proven true, all the docs should state the same thing. Just fond this while checking the other functions the script uses

And here

Has GL.Color before the GL.Begin

#Facepalm