Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: RenderTexture blurry when scaled up  (Read 2153 times)

0 Members and 1 Guest are viewing this topic.

vokazoo

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
RenderTexture blurry when scaled up
« on: October 14, 2024, 12:58:42 am »
Hello,

I have an issue when drawing to RenderTexture and then its texture to RenderWindow. For context, when window gets resized I'm using viewport to fill the window as much as possible while keeping original aspect ratio with letterbox effect and while keeping original view size. That way the resolution always stays the same and image just gets scaled to fit in window. That is working well, but I noticed that if window size is greater than view, RenderTexture gets blurry when drawn through Sprite much more than when drawing directly to window. I tried with setSmooth but didn't help. There is no scaling, shaders or anything similar at play other than changed viewport.

What can cause this and how to make RenderTexture appear the same as it appears when drawing without it?

Thanks


The attachment shows what drawing looks like when drawing straight to window (no RenderTexture) vs. when drawing to RenderTexture and then to window.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: RenderTexture blurry when scaled up
« Reply #1 on: October 19, 2024, 05:49:59 pm »
The render texture is blurry because it is smaller than the final image and then scaled up (as you pointed out in the title). As always, if a smaller image is scaled up, there is less detail and can appear blurry.
Remember that drawing to a larger window directly is effectively drawing to a large surface/texture so it can be expected that it would allow more detail.

The simplest way to combat this is to just make the render texture larger. Scaling down is usually less blurry.
You can start as large as you expect it to be or you can recreate the render texture after resizing the window. It can be relatively slow to recreate a render texture; just keep that in mind.

If the render texture would be far too large, you could consider one of exactly half size (in each dimension) and then scaling up. Removing smoothing would keep this nice and sharp.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*