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.

webgl2 and multisamplerendertarget

See original GitHub issue

now that threejs has switched officially to webgl2, could pp perhaps optimize with a flag or something so that we get native MSAA instead of having to use SMAA as an effect pass?

@looeee wrote down the basic steps here: https://discourse.threejs.org/t/advantages-disadvantages-of-using-webgl2/7717/7

const composer = new EffectComposer(renderer, {
  frameBufferType: HalfFloatType,
  webgl2: true // ?
})

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
vanruesccommented, Aug 3, 2020

Is it just SSAO or have you found other passes that exhibit problems?

I believe it affects every effect that uses depth (SMAA with depth-based edge detection, DoF & SSAO). The OutlineEffect should be fine, but I haven’t checked.

This article by Matt Pettineo explains MSAA in detail and says that “The coverage and occlusion tests are both performed at higher-than-normal resolution, which is typically 2x through 8x” and “For occlusion testing, the triangle depth is interpolated at each covered sample point and tested against the depth value in the z buffer. Since the depth test is performed for each subsample and not for each pixel, the size of the depth buffer must be augmented to store the additional depth values. In practice this means that the depth buffer will [be] N times the size of the non-MSAA case. So for 2xMSAA the depth buffer will be twice the size, for 4x it will be four times the size, and so on.”

The size difference of the depth texture is probably what’s causing the artifacts. This post by Phil Fortier has a section called “MSAA and SSAO together” that briefly mentions MSAA artifacts. Afaik, there’s no obvious go-to solution for this other than maybe re-rendering depth into another render target.

Have you tried using MSAA as a separate pass?

It’s been a few months since I’ve worked on this and I haven’t taken any notes. However, I remember trying to blit/resolve the anitialiased image into another non-multisampled render target before running SSAO, but that didn’t remove the artifacts.

2reactions
vanruesccommented, Aug 2, 2020

MSAA support was added in postprocessing@6.13.0. Note that some effects don’t work well with MSAA. See the wiki for details.

const context = renderer.getContext();
const maxMultisampling = context.getParameter(context.MAX_SAMPLES);

const composer = new EffectComposer(renderer, {
  multisampling: Math.min(8, maxMultisampling);
});

// Disable MSAA (creates new frame buffers).
composer.multisampling = 0;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multisample render buffer for post processing in a WebGL2 ...
I'm using a multisample render buffer for post processing using three.js. I use a multisample renderbuffer for both read and write buffers in ......
Read more >
WebGLMultipleRenderTargets – three.js docs
A special render target that enables a fragment shader to write to several textures. This approach is useful for advanced rendering techniques like ......
Read more >
WebGL2 render to texture with MSAA anti-aliasing and ...
Therefore, I'm setting up rendering pipeline with a multisample renderbuffer to render to a target texture. Anti-aliasing seems to work, however if I...
Read more >
Multisampling over Multiple Render Target - mrdoob/three.js
Hello! WebGL2 enables MSAA which is a great antialiasing feature. On top of that, the recent introduction of Multiple Render Target on threejs ......
Read more >
WebGLMultisampleRenderTarget - Verge3D User Manual
A special render target that can be used to utilize multi-sampled renderbuffers. Heads up: WebGLMultisampleRenderTarget can only be used with a WebGL 2...
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