Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 7, 2019

This PR adds support for multisampled renderbuffers. If you are using WebGL2, you can now perform "render-to-texture" and have an antialiasing render result. A post-process AA like FXAA is not necessary anymore.

Thanks to @mattdesl for his initial PR #8120

@mrdoob mrdoob added this to the r101 milestone Jan 7, 2019
@mrdoob
Copy link
Owner

mrdoob commented Jan 7, 2019

What happens if someone uses WebGLMultisampleRenderTarget while using WebGL 1? Should we fallback to normal WebGLRenderTarget in that case?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 7, 2019

For now, I would not implement a fallback WebGLRenderTarget and refer to the documentation. It's clearly stated that it's a WebGL 2 feature. If people start to complain, we can still try to figure something out.

FYI: If you still try to use WebGLMultisampleRenderTarget without a WebGL 2 rendering context, you get a runtime error since certain API calls like blitFramebuffer are not available under WebGL 1.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 7, 2019

Okay, d9c90c0 ensures that no runtime errors occur anymore. Instead, a warning is logged when WebGLMultisampleRenderTarget is used with WebGL1.

@mrdoob mrdoob merged commit c4b7b42 into mrdoob:dev Jan 7, 2019
@mrdoob
Copy link
Owner

mrdoob commented Jan 7, 2019

Thanks!

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 7, 2019

Yay 🎉 🙌 !

@carstenschwede
Copy link
Contributor

Awesome! Would it be difficult to do the same for WebGLRenderTargetCube?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Feb 18, 2019

I'm not sure how much effort it takes but I think it should be possible. What is your use case for this?

Normally, multisampled FBOs are mainly used in context of post-processing.

@carstenschwede
Copy link
Contributor

carstenschwede commented Feb 18, 2019

I use WebGLRenderTargetCube to simulate video projectors in THREE.js. The geometry that is being projected onto looks up its color according to the rendertarget texture. Your addition of multisampling renderbuffers allows better quality at lower resolutions and is much faster than manual MSAA. However, while a simple WebGLRenderTarget is sufficient for pinhole like projectors, I use a RenderTargetCube to project larger field of views using multiple projectors. The scenery is basically surrounded by a large envMap that is being dynamically rendered to using a RenderTargetCube. (Think of it like a planetarium).

Having a WebGLMultisampleRenderTargetCube would improve the rendering quality tremendously.

@mrdoob
Copy link
Owner

mrdoob commented Feb 19, 2019

@carstenschwede Would you like to create a new issue for it?

@mrdoob
Copy link
Owner

mrdoob commented Dec 10, 2021

@Mugen87 Would you like to explore removing WebGLMultisampleRenderTarget and adding multisample (default 0) and .setMultisample() to WebGLRenderTarget instead?

That way WebGLRenderTargetCube and WebGLMultipleRenderTargets will gain multisample support for free (API wise).

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 10, 2021

Okay, I'll have a look at this 👍 .

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 10, 2021

First draft: Mugen87@3d504a9

https://raw.githack.com/Mugen87/three.js/3d504a9328fa8d92c456310a45806c4f648eb22b/examples/webgl2_multisampled_renderbuffers.html

@carstenschwede
Copy link
Contributor

Awesome! Just to be sure: This enables multisampling for WebGLCubeRenderTarget?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 10, 2021

No, not yet. This PR adds no new features.

Cube map support is missing as well as resolving the multisampling to the default framebuffer (see #21573 and #22066).

@carstenschwede
Copy link
Contributor

Thanks, I see, so API preparation for later support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants