question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable "auto" logarithmicDepthBuffer only when EXT_frag_depth supported

See original GitHub issue

Issue: some devices exhibit artifacts with logarithmicDepthBuffer = true on the scene renderer when WebGL extension EXT_frag_depth is not supported by the device.

Impact: undesired artifacts, especially for objects close to the camera

Instead: if scene renderer attribute logarithmicDepthBuffer = auto, set this renderer setting logarithmicDepthBuffer true only if EXT_frag_depth extension is supported.


Psuedo code suggestion, starting here: https://github.com/aframevr/aframe/blob/67d568c263173ef0a56efc1e0d9e08a6f2d2d2a8/src/core/scene/a-scene.js#L609

// Existing logic
if (rendererAttr.logarithmicDepthBuffer && rendererAttr.logarithmicDepthBuffer !== 'auto') {
  rendererConfig.logarithmicDepthBuffer = rendererAttr.logarithmicDepthBuffer === 'true';
}

// Additional logic
if (rendererAttr.logarithmicDepthBuffer == 'auto' && renderer.extensions.get('EXT_frag_depth') !== null) {
  rendererConfig.logarithmicDepthBuffer = rendererAttr.logarithmicDepthBuffer === 'true';
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jbaicoianucommented, Jan 13, 2020

One trick I’ve had success with in the past using regular depth buffer is to dynamically update your near/far parameters based on the contents of the scene, and their distance to the player. Normally the type of z-fighting you’re dealing with in your scene is only visible when you zoom out, in which case the default near parameter is unnecessarily small. The closest object to the camera may be 10s or 100s of meters away so precision of 1cm isn’t necessary.

0reactions
kfarrcommented, Jan 13, 2020

I suppose you’re right, this “magic” auto behavior really isn’t that useful for general cases.

So really what I proposed is more of a short-term hack and shouldn’t be promoted behavior in A-Frame. Best to close this then and look for better solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebGLRenderer#logarithmicDepthBuffer – three.js docs
autoUpdate: Enables automatic updates to the shadows in the scene. ... buffer - Uint8Array is the only destination type supported in all cases, ......
Read more >
Threejs:How to set logarithmicDepthBuffer flag when rendering?
Use logarithmic depth buffer is a very simple change, just enable logarithmicDepthBuffer when create THREE.WebGLRenderer like so:
Read more >
Logarithmic Depth Buffer - Babylon.js Documentation
StandardMaterials can enable the logarithmic depth buffer if the browser supports GL_EXT_frag_depth extension. To enable it, just use this code: material.
Read more >
Hybrid Multi-Frustum Logarithmic Depth Buffer - Cesium
This is an optimization since writing the fragment depth in the fragment shader disables the early depth test optimization in GPUs.
Read more >
Logarithmic Depth Buffer - Game Developer
We will be dealing with it by requiring certain minimum tessellation. Also I think I've read somewhere that some forthcoming generation of hardware...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found