Corrupted alpha-mapped textures on layered polygons

I’m trying to make several layers of clouds above the terrain (observed from above, like from an airplane) using flat polygons with textures with alpha-maps. When I put two layers of such clouds, and the camera is Y-axis forward Z-axis up while terrain and clouds are parallel to XY-plane (so, the camera is looking towards the “horizon”), some visual corruption occurs to the upper layer of clouds. If I very slightly tilt the camera downwards (set its pitch to say -0.1 degree), the corruption dissapears. Here are the two snapshots:

Proper:

Corrupted:

Tested under Windows and Linux, but both on Radeon cards. Can this be something related to the video driver? Using Panda 1.6.2.

Hm, that look suspiciously like a transparency issue to me.

First of all, make sure that the ground object itself has no transparency enabled, to make sure that it’s not a conflict caused by two transparent objects (I assume your ground doesn’t have semi-transparent or transparent parts).
If that’s not the issue, read more on this page:
panda3d.org/manual/index.php/ … d_Blending
Try and see if one of the more advanced modes, like MDual, gives better results.

(I’m not sure if I was clear in my message, but while the terrain is not transparent, there are two layers of clouds above the terrain, at different altitudes, each a 2-triangle square with transparent texture.)

Darn, I missed to read that page, though it didn’t help.

The textures indeed had alpha channels (though from Gimp), but removing them didn’t change anything.

Setting transparency attribute to MDual or MMultisample changed things such that there was no corruption any more (I think), but the texture somehow lost its areas of higher transparency (i.e. that page mentions this is better for cutouts, sharp edges).

Turning off depth write did remove the corruption and kept proper transparence, but when the cloud layers move, visually they jump over one another without any particular order, causing flicker-like effect.

When I split cloud layers into 10000 triangles instead of 2, the corruption was still the same as on the image above.

The textures are PNG, but I tried also converting them to TGA and TIFF (after removing alpha-channels), no change.

You are experience depth-sorting issues, as described on the linked page. It’s important to render transparent objects in the order from farthest to nearest, and that’s difficult to determine with large, flat sheets stacked on top of each other like pancakes.

If you can determine programmatically the correct order to arrange the cloud sheets (for instance, if you know that one is always above the other), then you can use setBin() to specify the ordering explicitly. This is probably the best solution in your case.

If this is not possible to do reliably, then you will have to use some other solution. One possibility is multisample transparency, but this requires enabling multisample bits in your framebuffer, and it doesn’t work on all graphics cards. I believe the linked page explains this too.

Splitting the mesh up into lots of smaller polygons will only work if you also split it up into lots of individual meshes, so that each smaller piece is its own object. This obviously has performance implications of its own, but it should be reliable.

David

On my setup multisample transparency does something that is better than the original corruption, but still far cry from what it should be. And chopping into individual meshes I cannot do because of performance.

Now I’ve looked more closely into this manual ordering, and that really does solve the problem for the clouds and terrain alone. I’ll just have to think about interaction with other, smaller transparent objects (classification by bins…).

Thanks, people!