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.

SsaoPass: artifacts with depth buffer

See original GitHub issue
Description of the problem

The SSAO example shows several artifacts when i change the camera settings. In particular, the camera near clipping plane value is critical therefore. For a project of mine i need a small camera near value, but when setting up a useful value z-fighting artifacts occure. Both on the beauty and the ssao output mode.

artifacts

When switching off the depthTexture of beautyRenderTarget in SSAOPass.js, the beauty output mode delivers a useful rendering again, but then the depth information is missing of course.

	this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
		minFilter: THREE.LinearFilter,
		magFilter: THREE.LinearFilter,
		format: THREE.RGBAFormat,
		// depthTexture: depthTexture,
		// depthBuffer: true
	} );

Another attempt was to use the logarithmic depth buffer on THREE.WebGLRenderer, but the reimplementation 2f9bd63 seems not to contain a normalization regarding the logarithmic nature of the depth buffer.

I’d like to know how to achieve a good effect with the logarithmic depth buffer. What is the data type and the value range of the depth texture and why is only the x (or red) channel of interest. Next i’d like to know why the rendering quality seems to increase when i switch off the depthTexture (as seen in code above) for the beauty pass?

Three.js version
  • r110
  • r103
Browser
  • All of them
  • Chrome
  • Firefox
OS
  • Windows
  • macOS
  • Linux (on my linux installation on the same intel hd-gpu powered laptop there are no issues)
Hardware Requirements (graphics card, VR Device, …)

Depth / Stencil Bits: [24, 8] extensions WEBGL_depth_texture and EXT_frag_depth are available

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vanruesccommented, Mar 4, 2020

Sure, that sounds reasonable. My intention is just to provide another opinion on the matter.

1reaction
vanruesccommented, Mar 4, 2020

Does this have no side effects?

I haven’t encountered any issues with this depth texture setup. As far as I can tell, WebGLTextures already contains code for handling DepthStencilFormat and it also seems to handle stencil buffers correctly.

Stencil + Depth Texture support was added in #9368 which came after #8596 but didn’t close or reference the latter, although @Bryce-Summers reported that this PR fixed his CSG problem. Depth/Stencil management was also further enhanced by #9774.

I’ll check again if there are any problems with using stencil + depth texture and will report back later.

UNSIGNED_INT_24_8_WEBGL enables only a 24-bit depth texture whereas float enables 32-bit. so it’s not equivalent.

That’s true. I can only speak for myself, but to me 24-bit depth appears to be sufficient.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSAO - LearnOpenGL
The technique uses a scene's depth buffer in screen-space to determine the amount of occlusion instead of real geometrical data. This approach is...
Read more >
Vulkan - Strange artifacts with MSAA depth buffer
Hello everyone, I keep seeing these artifacts when trying to store an MSAA depth target from one pass, and then use it for...
Read more >
Multiple-passes SSAO border artifact - webgl - Stack Overflow
draw the geometry and store the depth vales in a texture buffer; apply the SSAO pass (based on this Fiddle from Rabbid76); at...
Read more >
A Simple and Practical Approach to SSAO - GameDev.net
An occlusion buffer is generated by averaging the distances of occluded samples to the depth buffer. However this approach has some problems ( ......
Read more >
To z-prepass or not to z-prepass - Interplay of Light
Having a depth buffer early in the rendering pipeline, other than improving overdraw, can open the way for many techniques and optimisations, ...
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