WebGL - Z-fighting in 3d

In this episode, I discuss z-fighting in WebGL and polygon offsets to fix it.
Concepts:
  • 3d: Z-Fighting
  • When two-primitives have the same / identical values in the z-buffer

  • APIs
  • gl.POLYGONOFFSETFILL //Activates adding an offset to depth values of polygon's fragments.
  • gl.polygonOffset //The offset is added before the depth test is performed and before the value is written into the depth buffer.

Resources:
  • https://github.com/davidwparker/programmingtil-webgl/tree/master/0060-3d-zfighting
  • https://en.wikipedia.org/wiki/Z-fighting
© programmingtil.com