Understanding how BJS deal with antialiasing with and without pipeline

It’s not the first time I’m wondering why on webGL1 devices (yes I see you Safara on iOS…) we have a nice default antialiasing but as soon as we activated the default rendering pipeline it’ becomes hard to get rid of aliasing.

This topic is to help me to be sure about a bit of informations before updating this doc page, so everyone can know all limitations: Use the default rendering pipeline - Babylon.js Documentation

There is already info about that but we miss the “why” I think:

The MSAA antialiasing (only supported in webGL 2.0 browsers) effect is off by default (set to 1) but can be turned on to 4x

By reading this TrevorDev github answer + this old topic I’ve opened, this is my proposals to add to the doc, correct me if I’m wrong (and by the way, is MSAA clamped to 4? - and let’s ping @Deltakosh & @trevordev :wink: ):



The MSAA antialiasing (only supported in webGL 2.0 browsers) effect is off by default (set to 1) but can be turned up to 4x with:

pipeline.samples = 4;

and the FXAA antialiasing effect can be set using:

pipeline.fxaaEnabled = true;

Note that without using the pipeline, your scene already use a MSAA antialiasing, which is webGL native. When enabling the pipeline, you’re actually start using a post-process texture. Unfortunatly, webGL 1.0 devices will not be able to apply MSAA outside of render buffers. Still, FXAA is available but not as powerfull as MSAA.

That’s a short addition but can help everyone to better understand why this aliasing show up on some devices (yep, again, iOS…)


Looks perfect to me, would you mind doing a PR on the doc ???

Great, of course about the PR, this thread was about that :wink:

What about the MSAA value, if we set a value greater than 4 is it took into account?

It will fallback to the maxed values allowed by the hardware that we query from the webgl context :slight_smile:

1 Like

job done! pipeline informations by Vinc3r · Pull Request #1808 · BabylonJS/Documentation · GitHub



I will merge in a sec thanks a lot

To add to this in case people care in the future. For webVR/XR MSAA is not supported when multiview is enabled, still hoping this gets added to the spec Multisampled multiview support · Issue #2912 · KhronosGroup/WebGL · GitHub