All Questions

Community

K
Orestis Konstantinidis
posted to: Optimization

Where is the half-scale?

Hi, some wonderful tips here.

After finishing the "Blurring at half scale" part, I'm missing the part where we actually use half-scale. Unless I'm missing something obvious, it doesn't look like we set up any of the TextureRects to use half-scale.

If I'm not seeing it, could you point out where the half-scale takes place?

  • Nathan Lovato replied

    You render at half-scale by setting your blur Viewport nodes' resolution to half that of the project. You can go even lower than half for faster processing, although you may start to get visual artifacts.

    The resolution you need on the Viewport nodes depends on the project's window settings. For instance, if your project is set to render at 1280x720, you want to set your two blur views' viewport to render at a resolution of 640x360.

    I hope this clarifies how it's meant to work.

  • K
    Orestis Konstantinidis replied

    Hi Nathan,

    do you mean the Viewport nodes or the Viewport containers? If I resize the Viewport nodes, they reset back to full res after reloading the scene. Resizing the containers does work but I have a question:

    1. This is the full res image
    2. This is when reducing the resolution of Blur2
    3. This is when reducing the res of Blur 1 as well


    As you can see the aspect ratio of the texture becomes distorted. This only happens if I reduce the Y size of Blur1. My Window resolution is the default 1024x600. If I set it to 512x300 it becomes like that. If I set it to 512x600 then it preserves the proper aspect ratio.

    Question: Are we supposed to blur only Blur2? Or both and use (Half Res) x (Full Res) on Blur1? Or am I doing something wrong?

    Furthermore, you can see from the screenshots that the scaled up image is pixelated. I expected it to be blurry as described in the tutorial, but it seems it's using Nearest Neighbour by default. I figured out we can use the "Filter" flag in the ViewportTexture of the Presentation Layer to blur it while scaling it up.

    I think the above clarifications would be useful to be mentioned in the tutorial.

  • Nathan Lovato replied

    I'll pass that to François for the details, and update the lesson based on your discussion.

  • Razoric replied

    You can reduce both phase 1 and phase 2 of the blur.

    If you use a TextureRect to show the result, then you can blur both with half scale viewports - so long as the TextureRect that is showing the image takes up the full screen and is set to expand its image.

    If you are using a ViewportContainer to show the result, the one that does the presentation should be full screen and instead use the Stretch Shrink property to halve (or more) the child viewport without having to manually set the resolution manually.

    However, regarding the aspect ratio: if you reduce the size, you need to reduce it following the aspect ratio. If you want a 50% reduction in size, then both the X and Y need to be reduced by half, or else you will run into distortions like in your third image.

    And finally, some pixelization is to be expected; you are working at half scale. If the effect is too unacceptable, however, you can opt to only blur the first phase. Or, yes, make sure Filter is active.

  • K
    Orestis Konstantinidis replied

    Hi, thanks again for the replies!

    use the Stretch Shrink property to halve (or more) the child viewport without having to manually set the resolution manually.

    This is the part I was missing, didn't realize it had a built in parameter for that purpose!

    regarding the aspect ratio: if you reduce the size, you need to reduce it following the aspect ratio. If you want a 50% reduction in size, then both the X and Y need to be reduced by half

    So I'm still a bit unclear about this, perhaps I'm doing something wrong. When I use the Stretch Shrink, both X and Y are reduced appropriately. But I still get aspect ratio distortion. Maybe I'm doing something wrong here....

    I'm attaching my project if you'd like to have a look.

  • Nathan Lovato replied

    I'm updating the course right now. Sorry for the reply delay, I missed your message. Please ping me anytime if we don't get back to you within a few business days.

    Testing your project, I can confirm that Stretch Shrink causes a a distortion in your project. Turning it off and manually downscaling the Viewport node's Size property instead does not produce this artifact. To me, this suggests there is a bug in the ViewportContainer node.

    The bug doesn't happen in our demo project, where the base resolution is 1920 x 1080. I wonder if it's the project resolution that makes the difference there.

  • K
    Orestis Konstantinidis replied

    Thanks for the update Nathan!