I have a little problem I did not solve for some time: If I have transparent blocks (ice, glass, etc.) sliding on a flat surface I get z-Fighting on the bottom of the blocks (using two pass transparency in transparent queue and one sided lighting):
Any clever ideas to solve this problem?
Use polygon offset, Renderer.setPolygonOffset() & Renderer.clearPolygonOffset(). See this page for more info.
Well I can create really nasty effects with that, but it does not affect the transparent stuff
Hmm, perhaps rendering the floor first, then clearing the zbuffer? (Assuming you, and objects, do not go below the floor)
irrisor said:
Well I can create really nasty effects with that, but it does not affect the transparent stuff :(
You need to render your scene first, then render the transparent blocks with the polygon offset.
Try rendering your blocks in a separate pass and use Pass.setZOffset to set the offset.
renanse said:
Hmm, perhaps rendering the floor first, then clearing the zbuffer? (Assuming you, and objects, do not go below the floor)
good idea, but I have floor pieces that possibly occlude transparent things
Momoko_Fan said:
You need to render your scene first, then render the transparent blocks with the polygon offset.
wow, that really works smoothly, thanks! 8)
I did not really get it from the link you posted, sorry.
@renanse (and other devs): should we probably change rendering the transparent queue like this, by default:
renderer.setPolygonOffset( -1, 1 );
renderTransparentBucket();
renderer.setPolygonOffset( 0, 0 );
(possibly only if polygon offset is 0,0 before)
It does not seem to harm other application (can't see anything in the tests at least).
I don't know… If we did add such, it should be with non-hardcoded numbers at the very least.