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: https://doc.babylonjs.com/how_to/using_default_rendering_pipeline

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: ):



Customizing

Antialiasing

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…)

2 Likes

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:

2 Likes

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

image

3 Likes

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

3 Likes

was looking at this thread. We have an issue on ipad pro where it looks like msaa is ether turned off or using a lower value than what we have set up ( pipeline.samples = 4). How do I query what is the max allowed samples on the device. It feels to me like on mobile using FXAA might be better?

engine.getCaps().maxSamples will give you the maximum MSAA samples supported by your GPU, and engine.getCaps().maxMSAASamples is the actual maximum used by Babylon. It can be different if we detect a faulty OS: in that case, we set maxMSAASamples to 1.

1 Like