Squared screenshot

Hello !

So I’m currently using the CreateScreenshotUsingRenderTarget function and my problem is the following one :

What I want is to check if a mesh list is completly in the current camera frustum and if it’s the case I take the screenshot. The predicate works well.
However when I set a number as size (like 256) I get a squared screenshot like I wanted but as the camera view is croped some of my object are not in the image anymore.

 BABYLON.Tools.CreateScreenshotUsingRenderTarget(
            this.engine,
            currentCamera,
            256,
            callback
            "image/png",
            8 // number of samples
        );

Is there a way to take a squared screenshot by avoiding to crop the width and keep all of my object inside the screenshot ?

Unfortunately the system will always take the viewport and the aspect ratio in account. if you change the aspect ratio then the projection matrix will change and then some meshes will be not visible.

It is exactly like doing it manually:

  • You render your scene to a rectangle image
  • You use paint.net or photoshop to make it square: then either you add black borders or you need to remove bits from the original image

Only way to have it square is to have the initial canvas square

I did this once with PHP, which trimmed the image to make a square.