Enable "auto" logarithmicDepthBuffer only when EXT_frag_depth supported
See original GitHub issueIssue: 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:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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