Alpha Blended Textures problem

Hello, all

I am trying to get two transparent (alpha channel) objects to overlay each other.

Two objects are created with transparent textures from 32BPP TGA files (24BPP + alpha channel).

When looking through transparent parts of the objects, any solid objects behind it will be visible, but other transparent (alpha-mapped) objects sometimes disappear, depending, apparently, on the angle.

I tried playing around with settings, giving functions different parameters in hopes of fixing the problem, but nothing works. Any suggestions anybody?

Sergey

same problem here. with png its very odd.

for your every day objects

// src=BLEND_SRC_ALPHA, dst=BLEND_ONE_MINUS_SRC_ALPHA

good for particles

// src=BLEND_SRC_ALPHA, dst=BLEND_ONE

but i do get a strange outline on objects where things should still be a smooth aplha blend.
its as if u cant see past areas that the edges of the textures alpha.
This only happens at some angles- even with billboards. very odd

im loading textures like this:


texture = (Texture2D) tloalder.constructTexture(
        bufferedImage,
        "RGBA",
        false,
        Texture.BASE_LEVEL,
        Texture.BASE_LEVEL_LINEAR,
        Texture.WRAP,
        false,
        TextureLoader.SCALE_DRAW_BEST);

looking into this more at the moment.

Fixed it.

Well, it seems that every OpenGL based engine has the same problem, I don’t know about Direct X, but the “problem” is related to the depth Z-buffer.
To solve the problem I created RenderingAttributes and set setDepthBufferWriteEnable(false) on it, then I enabled sorting on Transparency attributes, and finally I set the View transparency policy to:

view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_BOUNDING_SPHERE_AND_EYE_RAY_INTERSECTION)

This fixes the problem as long as the polygons don’t intersect, and as long as they are not very close to each other. Xith will sort all the polygons in the scene BACK to FRONT, but this sometimes doesn’t work as expected. The way around this problem is to create bounding sphere for every transparent geometry and position them along one axis in the required order.

Sergey

cool nice one- now only if i could sort of this bounds
problem on a BillBoard :frowning: sodding things just vanish…

setDepthBufferWriteEnable(false) works great!
thanks again…

Hi,

[quote]Well, it seems that every OpenGL based engine has the same problem, I don’t know about Direct X, but the “problem” is related to the depth Z-buffer.
[/quote]
Yes, rendering the transaprent objects is tricky for both OpenGL and DirectX, especially if you want to corectly render intersecting semi-transparent polygons or self-intersecting surfaces.

Currently to render semi-transparent shapes in Xith3D, you have to

  1. Ensure that they will render on Transparent rendering pass (for example, set BLENDED transparency mode for TransparencyAttributes)

  2. Ensure that geometry sort is enabled

  3. Disable depth buffer writes for transparent objects

  4. Choose the transparency sorting policy (check source and JavaDoc for details on each sorting policy).

[quote]I enabled sorting on Transparency attributes, and finally I set the View transparency policy to:

view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_BOUNDING_SPHERE _AND_EYE_RAY_INTERSECTION)

This fixes the problem as long as the polygons don’t intersect, and as long as they are not very close to each other. Xith will sort all the polygons in the scene BACK to FRONT, but this sometimes doesn’t work as expected.
[/quote]
TRANSPARENCY_SORT_BOUNDING_SPHERE _AND_EYE_RAY_INTERSECTION is a best and reasonably fast implementation I found for geometry sorting. If you have a better idea for it, lets discuss it - would be really great if we can enhance the transparency rendering [one of the approaches is to use more complicated bounding shapes, but this degrades performance very much].

To completely solve this kind of problems, we should implement some of multipass/miltiphase techniques for transparency rendering, which implements per-fragment (per-pixel) depth sorting and works perfect in every case, including intersecting polygons and self-intersecting surfaces. The good example for such technique is depth peeling, but it works efficiently only on newer hardware and requires more rendering passes.

Yuri

if its faster cant we added it with a flag so if users
dont have the hardware they can roll with the
none hardware version

a hardware version sounds great to me mind.
and ied love it!