NativeEngine render target texture not working with MSAA

Hi all, we’ve got a native based renderer working pretty good but its falling back to WebGL1. (we’re trying to use MSAA and getting that familiar error where it says MSAA is only supported in WGL>=2.0
I tried looking at vendor/version via getGlInfo() but nothing is filled in, everything is undefined here. Probably not implemented in the NativeEngine wrapper im guessing? Anyway, anything i can check to see what might be causing NativeEngine to use WGL 1?

We’re just instantiating like this:
engine = new NativeEngine();

cc @BabylonNative

@Anupam_Das Can you send a repro or show what you are doing? NativeEngine does not use WebGL1 or 2.

sorry I misspoke regarding webgl, not webgl but more broadly that MSAA isnt working as expected. Found this:

which makes me feel like MSAA is not implimented.
but then there is this:

which makes me feel it is implemented :slight_smile:

I’ll send you a bit more info tomorrow AM on our setup.

Sorry, yes, MSAA for the default back buffer is implemented, but MSAA for render target textures is not. You probably need the latter. We can probably investigate how to implement it.

Yes we need that for render target textures for our backend renders. Do you have a feeling of level of effort, if you guys could look into this that would be hugely beneficial or provide guidance. Happy to jump on with you to talk it through.

Also here is how we do our rendering… pretty basic and straight fowrard.

const outputTexture = new BABYLON.RenderTargetTexture(
                    width: parseInt(snapshot.width),
                    height: parseInt(snapshot.height)
                    colorAttachment: output,
                    generateDepthBuffer: true,
                    generateStencilBuffer: true

            const camera = scene.renderer.getMainCamera();
            camera.outputRenderTarget = outputTexture;
            await babylonScene.whenReadyAsync();

Ok, I haven’t looked into how to implement, but it hopefully isn’t too difficult. Let me see if I can find some time to look in the next couple of days.


that would be amazing Gary! Thanks so much. The results we’re getting is really amazing and we are so close ! keep us updated.


I got something working locally. I should have a PR ready soon. I’m also going to update the Babylon Native example with this change.


omg amazing Gary thanks so much!! ping me when its up will test it out right away,


@bghgary do you have this in a branch somewhere ? ( i couldnt find it on the native repo) would love to just give it a test sometime this week if possible.

I do, but I’m still trying to work out the kinks and get it in a PR. I’ll let you know as soon as it’s possible to test.

sounds good thanks!

Babylon.js npm package: Use 6.12.5
Babylon Native: Use PR Basic support of MSAA for render targets by bghgary · Pull Request #1261 · BabylonJS/BabylonNative (
Babylon Native Examples: Update console app to use MSAA in render targets by bghgary · Pull Request #7 · BabylonJS/BabylonNativeExamples (

Hopefully that’s enough to figure out how to enable MSAA in render targets. Let me know if you have any issues or questions.

we’re testing this today. thanks!

@bghgary we ran through the above steps carefully but unfortunately we’re still not seeing any impact based on our input sample count of 4. We are getting an image but does not seem any different than without multisampling. Our app closely mirrors the sample app with the addition of our own business logic but otherwise almost identical. We’re also not doing the error checking your doing on the sample app ( CatchAndLogError…etc) but I dont see how that could be related.

If you have any debug steps we could try happy to try that. Scratching my head on this one…

update: We got it working as long as we dont have a transparent background. The way we handle transparent backgrounds is like this and in that case MSAA does not work. (we’re rendering a BG camera and main FG camera and comping them together) similar to this:

from this thread:

investigating this today. If you have any thoughts please chime in.

I’ll investigate and get back to you. Sorry for the troubles.

EDIT: If you can send a copy of index.js from BabylonNativeExamples modified to repro this behavior, that will help a lot.

I’m trying to repro with the code from the PG link you referenced, but the JavaScript is throwing an exception about Unsupported texture format or type. I’m guessing that’s not what you are seeing. Can you provide a repro for me?