Having different render target size

I’m just wonder if my question is possible in playcanvas.

Normally, a camera created in studio,it has the same render target width and height as the screen.

The problem is if I want to take a screen capture with different resolution, it always create the buffer which has the same resolution with the screen.

    RenderTargetControl.prototype = pc.extend(RenderTargetControl.prototype, {
        render: function (inputTarget, outputTarget, rect) {

            var device = this.device;
            var scope = device.scope;
            this.downloadTexture.downloadTexture(inputTarget.colorBuffer, "test", false, true);
            const colorBuffer = new pc.Texture(device,  {
                width: 512,
                height: 512,
                format: pc.PIXELFORMAT_RGBA8,
                cubemap: true,
                mipmaps: true,
                minFilter: pc.FILTER_LINEAR_MIPMAP_LINEAR,
                magFilter: pc.FILTER_LINEAR
            // Resize the output render target
            inputTarget.colorBuffer = colorBuffer;
            console.log("1st check for Input Target : ", inputTarget, inputTarget.colorBuffer.width, inputTarget.colorBuffer.height);

            inputTarget.colorBuffer._width = 512;
            inputTarget.colorBuffer._height = 512;
            console.log("2nd check for Input Target : ", inputTarget, inputTarget.colorBuffer.width, inputTarget.colorBuffer.height);
            // outputTarget.colorBuffer = colorBuffer;
            outputTarget.colorBuffer._width = 512;
            outputTarget.colorBuffer._height = 512;
            console.log("Output Target : ", outputTarget);

            pc.drawFullscreenQuad(device, outputTarget, this.vertexBuffer, this.shader, rect);            

I’ve tried to set up the render target resolution manually, but it still render the first frame with screen resolution.

Any consequent rendering (like following posteffect or multi sampling rendering), will render the resized resolution.

The problem is it just resize the initial buffer with the new resolution which led image ugly.


So, what I want to do is to have a camera with fixed (customized) resolution from the beginning.
Is it possible?

Hi @sooyong_Kim,

Hmm, when I had a similar issue in the past the hacky way I solved it to resize the viewport before/after the screenshot camera would render.

Though that was with a much older version of the engine, most likely there is a better way to do that right now. @mvaligursky any idea?

@Leonidas it seem to be possible with engine level but not possible with studio launch.

There is no way to set this up in Editor using user interface, you need a script to do this - to create a texture for render target of a size you need, and use some camera to render to it.

@mvaligursky so i have to create from a scratch including entity, camea, and render target. then apply other custom scripts and post effects to it.
is that right??

You can create entity with camera in Editor and leave it disabled. When you want to render the screenshot, create render target using script, attach it to the camera, enable camera, and on the next frame, render target should contain what it rendered. Copy it out, and disable the camera again.

I think we have some example project for this @Leonidas @yaustar ?

Right, I think this is the example:


Hmm, just tried it with the capture screenshot sample project fork with a custom size render target https://playcanvas.com/project/1074898/overview/different-size-screenshot

And it works fine on the first screenshot:

Can you create a repro project to look at please @sooyong_Kim