pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Z-fighting in LineRenderer

Open vorg opened this issue 3 months ago • 0 comments

Because our helpers now use one geometry there is a lot of z-fighting between e.g. bounding box of a floor and grid or axes and grid helpers.

Image

One solution would be to offset axes or grid on Y axis or use polygon offset but they would need to be seperate draw calls

//polygon offset example
const gl = ctx.gl
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(-i * 10, 1);
ctx.submit({
  name: "drawLineGeometryCmd",
  pipeline,
  attributes,
  count: (instanceRoundRound.length + resolution * 18) / 3,
  instances: entity.geometry.positions[0].length
    ? entity.geometry.positions.length / 2
    : entity.geometry.positions.length / 6,
  uniforms,
});
gl.disable(gl.POLYGON_OFFSET_FILL);

I would love to disable depthWrite in all line materials for helper as that produces cleanest renders but then our skybox is erasing lines

Image

vorg avatar Sep 19 '25 09:09 vorg