Problems with alpha and zbuffer

I’ve been messing with the AlphaState test Function with no luck.  It seems that triangles with textures that have full transparency pixels still write over the z-buffer.  I would expect that if a pixel had an alpha of 0 then it wouldn’t overwrite the z-buffer.



In the following pictures you see the normal image, and a 2nd image where I traced over the image where the triangles are. The mirror for the M1084 is basically a sprite attached to the cab.  Any ideas how I can get this to work correctly?  The mirror gets rendered after the cab, but before the bed of the truck, so you can see right through the truck bed where the mirror triangles are.  This same problem exists for the sides of the tires too.











And yes, that is an OpenFlt model I’m reading into jME natively :slight_smile:



-J

You can turn off z-buffer writing with a zbufferstate:



ZBufferState zs = display.getRenderer().createZBufferState();
zs.setWritable(false);



As a general rule I do this every time I put something in the transparent render queue.

I tried that, problem is the textures for the vehicle have alpha as well, so turning the zbuffer write off for everything w/ an alpha creates a wierd 'inside out'ish vehicle because of the render order.  I pretty much just want to disable zbuffer write on pixels with alpha=0.

Did you apply the z-buffer state to the mirror only? That shoulnd't affect the appearance of the rest of the vehicle.



Not sure there's an easy way to do it at pixel level (can't see it being too hard, though), really anything that is at all transparent will cause weirdness if it writes to the z-buffer.

Have you've tried using com.jme.scene.state.AlphaState with test enabled, reference somthing like 0.5 and test function TG_GREATER. It should be on the transparent objects.

setReference(0.5f) worked beautifully, thanks!