Alpha sorting issue

I’m trying to use a plane in front of the camera to have a fade out and fade in effect. All is nice and tandy, BUT
I’m having troubles blocking objects behind the plane with transparency.

I attached example blend with simplified setup.

I just can’t get my head around the issue as to why the logo element keeps itself visible, instead of getting blocked by the black plane.

alpha_issue.blend (1.1 MB)

Here it is being blocked! (?)

How is that possible. I have tried this on two pc. One on Windows and one on Linux and both are showing the logo not getting blocked by the black plane.

Yeah its a bug its been reported to the tracker a while ago. musikai’s saw that the text was blocked because the text is in fact blocked when the object blocking the text and the camera are perpendicular to the text object, which you can see by pressing 0 and then p.

I originally reported this bug as a render order bug but the view angle of the camera effects weather the text object is viewable or not. simple fix is either using post processing or setting your black fade plane to an overlay scene however this also causes another problem.

Maybe you could instead animate a value of the “ray to camera”. I’m sure there are even easier methods, but I like to try and accomplish tasks differently every time I try them. I like using the nodes to do things.

What’s that “Ray to camera” thingie? I have never heard of it.

Oh you are making a game intro? I finally looked at the blend file. Yeah man just render out the animation in blender render and pull it into the video editor and add a fade in and fade out if you like. Then render to .H264 avi. Then… I don’t make games… you set up ur intro to play the video at start up. Shouldn’t be hard.

Yeah don’t worry about the lightpath node which is what you were asking about. That is a pretty advanced node for rendering and doesn’t really apply to game making. I may be completely wrong about that though. I don’t yet know exactly how to use it myself. Just know it allows you to control all aspects of light in blender. Way overboard for what you are trying to accomplish.

Oh not an intro really. I’m trying to build a fade in/out function that I can call when ever needed.

Oh that is different. You know I bet that would be the perfect noob script to learn how to make. I’m positive there is many ways to accomplish this, but if ur interested in making games eventually it will help to know some python. I bet you could learn to do this in python in no time.

I’m sorry I don’t know much about the bge. Your idea should work. Try looking on youtube for how to fade a scene in and out. I just don’t know the right terminology for the bge. I wouldn’t know what to look for.

I used this method: Fading and Transparency for all Shading modes

It works with your demo file too at least in GLSL. I do not see the transparency in Multitexture.
“Menu_logo” gets blocked too.

edit: got it - enable Face Texture of material “Menu_Sheet” of “Menu_logo” too.

What I did:
I added a black one pixel texture (called it “black”). Unwrapped the blend and assigned the texture “black” in UV-Editor (blend turns black). Then I followed the guide from above link incl. the animation logic.

Enabled “Face Texture” of Menu_logo, otherwise the blend will not become transparent in Multitexture mode.

Let me know if you need your test file.
I hope it helps

I checked your tutorial also Monster and that brings me back to my original issue with alpha.
For some reason the alpha sorting is bugging for me so that the element behind my alpha object is showing through the object even though it shouldn’t. Here’s how the example blend behaves for me.


EDIT: Monster, I tried your latest tips and I just can’t it to work.
Both Multitexture and GLSL modes do the same.

got me at least at this laptop, this does not happen. The logo is hidden by the black plane.

It looks indeed like a sorting problem. Can you try if this happens even when the two planes have larger distances?

If the distance is greater than about 0.7 the alpha gets blocked and all works nicely. So this I can just get around by taking the camera further away. Still doesn’t make the problem truly go away.

Set the Transparency, Alpha 0.alpha_issue.blend (1.08 MB)

Now I see. You are looking from left onto the planes.

Oh and now that I use text objects in my game even my work around doesn’t work on those. No matter how far I take my camera, text objects refuse to be blocked by an object with Transparency.

I think these are two different issues.

The problem is that the sort algorithm has problems with overlapping objects. As you look from left front onto the planes the bounding boxes of both objects are intersecting each other. I think the algorithm does a best-bet calculation with the object centers, which unfortunately results in incorrect sorting.

There are two things you can do:
A) support the sorting, buy changing the dimensions of the second or the first plane and/or give them a larger distance.

B) switch the logo to clip alpha. This way it will not be sorted and uses the fast Z-Buffer rendering. (But you loose any semi-transparency)

Font objects are somehow different. I do not know how they are implemented, but they do not appear as normal objects. I had the problem that they are not visible in render-to-texture output.

My suggestion: Move the black plane much more near the camera (and make it smaller). As alternative - use an overlay scene with the camera and the plane only. After fading you can even remove the scene ;).

You can use a 2d filter :). Heres one I quickly made, hope it helps :slight_smile:


 uniform sampler2D bgl_RenderedTexture;
uniform float Fade;
    void main(void)
    {
        gl_FragColor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st).rgba*percent;
    } 

Just have a property on the object that adds the 2d filter called Fade. Setting it to 0 is faded out, while 1 is no effect. To make the fade out work just subtract from Fade each frame :).