Logarithmic Depth Buffer and webgl2 shader

Hi all.

Is there anyway to use a webgl2 shader with Logarithmic Depth Buffer support?

By now I have been using a workaround setting the near and far camera settings depending on the camera position, but it is not enough. My scene is very complex and many times I face the superposition issue.

Could anybody show me an example using Logarithmic Depth Buffer in a webgl2 context?

Many thanks in advanced.

Best regards

Are you talking about custom shaders or built-in materials? The official example seems to work just fine with a WebGL 2 rendering context (tested locally on my computer).


There is no issue with using logarithmic depth buffer and WebGL2.

This probably isn’t related to the depth buffer, you can only get depth fighting issues there, depending on what you mean with superposition. WebGL highest precision is 32 bit, on mobile it can be even just 16, if you use high values or too large distances from the origin there will be precision issues like jumping vertices, or flickering textures with huge uv coordinates, regardless using the logarithmic depth buffer. Same goes for using too small decimal numbers.


I will try to provide a fiddle example of my issue.

Many thanks in advanced

Hi Michael.

I am takling about using a custom shader material.

Best regards