Momoko_Fan said:
Try using material.getAdditionalRenderState().setPolyOffset(), what it does is alters the depth value of the pixel so you can kinda move it forward a bit so you don't have the artifacts.
That did the trick. Exactly what I wanted. No Z-buffer fighting any more, and i can keep my geometries exactly on the grid.
The only drawback is that the water surface is 'on top' viewed from the adjacent solid cube too, but I don't think that will ever be visible any way.
Solution:
[java]
float factor = -1.0f;
float units = -1.0f;
material.getAdditionalRenderState().setPolyOffset(factor, units);
[/java]
It took quite some googling to find out what the parameters meant and what values to put in. I have tried to patch the much needed comment to the code using the new google edit-file functionality, but after logging in and selecting the RenderState.java file it only showed the top third of the file in the edit window and wouldnt let me scroll down further.
So maybe one of you could put some comment in, Here is the background, method and parameter description.
I suggest
[java]
/**
* Offsets the on-screen z-order of the material's polygons, to combat visual artefacts like
* stitching, bleeding and z-fighting for overlapping polygons.
* Factor and units are summed to produce the depth offset. This offset is applied in screen space,
* typically with positive Z pointing into the screen.
* Typical values are (1.0f, 1.0f) or (-1.0f, -1.0f)
*
* @see http://www.opengl.org/resources/faq/technical/polygonoffset.htm
* @param factor scales the maximum Z slope, with respect to X or Y of the polygon
* @param units scales the minimum resolvable depth buffer value
**/
[/java]
Thanks :)