We’ve been working on adding an option for MSAA in CesiumJS with WebGL2 contexts - there’s a pull request open and we’d be happy to hear feedback from anyone interested in trying it out
The instructions are in the main pull request post, but the gist is to request a WebGL2 context in the Viewer constructor:
var viewer = new Cesium.Viewer("cesiumContainer", {
contextOptions: {
requestWebgl2: true,
},
msaaSamples: 4
});
Once a WebGL2 context is available the multisampling rate can be controlled with Scene.msaaSamples, which defaults to 1 (MSAA off).
This change is exciting to us because it’ll add another option for dealing with aliasing artifacts that are hard to fix with post-process anti-aliasing like FXAA. In particular, 3D geometry with small details or thin polylines and other edges should look a lot better with MSAA turned on. There are some limitations - MSAA does not affect effects that are applied in post-processing (i.e. outlines) - in these cases MSAA can be used with FXAA if needed. We are aware of a couple other issues that are listed in the pull request description. If you’re interested, please let us know if you notice any other bugs or have other comments about the changes, thanks!
I experience a bad performance bug still: on a machine with Nvidia RTX 3090 GPU even the empty sandcastle fullscreen runs about 25 fps. With scene.msaaSamples=1 fps is way above 60fps all the time. From my understanding this cannot be just normal performance penalty of MSAA, it has to be some error somewhere…
@v12424124_34 Thanks for testing it out and posting those details. I was able to reproduce the low frames on another 30 series machine, but not on other computers. We’re still looking into this and I’ll post updates here if we resolve it.
@v12424124_34 Interesting. We believe it’s an issue on Windows rather than the NVIDIA cards because we’ve been able to reproduce the frame drops on machines that dual boot Linux and Windows only on the latter. I’ve posted in the WebGL mailing list to see if anyone’s run into this before. Unfortunately with the CesiumJS engine it’s not easy to decouple the framebuffers’ depth-stencil and color attachments so I don’t know if there’s a quick fix for this.
I tried the blit without the stencil mask bit and it worked very well for me… I am now wondering what are the implications of leaving the stencil out? Does it affect only the classification etc. advanced stuff but not really the globe rendering?
On iOS 15.4 the MSAA got broken. It worked fine before the iOS update, but now it seems that depth buffer does not get cleared or something. Video in the zip: ios.zip (949.1 KB)
@v12424124_34 Ah bummer… Would you be able to open an issue on the CesiumJS repo with steps to reproduce? Attaching the ios.zip file would be helpful, as well as a screenshot of WebGL Report results on your device. Thanks!
Hi! Coming back to this again as we found yet another “blitStencil” bug. It goes to slow framerate-mode if you use it without terrain and with 3d tiles model in this example sandcastle. So the combination Msaa + 3dtiles bim + no terrain is slow still and it is caused by the blitStencil.