Sprites look blurry when scaled using im.Scale

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Ozitiho
Regular
Posts: 90
Joined: Mon Sep 22, 2014 3:29 pm
Location: Netherlands
Contact:

Sprites look blurry when scaled using im.Scale

#1 Post by Ozitiho »

So I was very concerned for a while with how to deal with resolutions and all that mess in Ren'Py and was messing around with that. My main concern was (and kinda still is) in what resolution to export my graphics and how to import them into the game. After deliberation I decided to make my sprites 2160px high so it supports Ultra HD. So then I had to downscale that.

I found two ways of downscaling. I find the somewhat messier method is to apply transform to all images, zooming them out to the desired resolution. My window resolution is 720px high so I zoomed them all with a factor of 0.333 like this.

transform downscale:
zoom 0.33333333333

image Satoru big = At("Sprites/Satoru/SATORU BIG.png", downscale)


The other way is to use im.Scale (or FactorScale) to bring them to the approriate size. I considered this a cleaner solution, as you can simply apply the desired height regardless of the source sprite (in case that might change at any point).

image Satoru big scale = im.Scale("Sprites/Satoru/SATORU BIG.png", 382, 720, bilinear=True)

However, for some reason I can't imagine, the scaled sprite looks blurry. While the zoomed sprite looks beautiful.

Is this intended? Am I doing something wrong?

In order to test it I've made the following scene

show Satoru big as a at left4
show Satoru big scale as b at right4
show Satoru casual grin at left

Satoru "test1"


"Satoru big" is zoomed, "Satoru big scale" is scaled with im.Scale and "Satoru casual grin" is downscaled to the appropriate size using the program is was drawn in.

Image
https://puu.sh/tyoDL/593bfe9210.jpg Click this link for higher resolution

I'm not very particular about graphic fidelity. But I'm pretty sure we can all agree the middle sprite is the cleanest and the right one is blurry and weird.

On closer inspection I also noticed my screen might be a lot higher than 720 pixels... But I have no clue what is up with that... Since my options read the following:
config.screen_width = 1280
config.screen_height = 720


So my question is really two things. Why does im.Scale look so bad? Is this intended behavior?
And secondly, I'm doing this to ensure people can go fullscreen with up to Ultra HD screens without the sprites becoming blurry, but also enabling players with a smaller screen to play. Is this the intended method? If not, what is?

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Sprites look blurry when scaled using im.Scale

#2 Post by nyaatrap »

Your game's window resolution is width: 1653px height: 960px.That why height 720 sprites are shown as upscaled. On the other hand, transform uses original size directory. To fix your game's window size, click 'window' on the preferences screen.
You almost always want to use transform, because im.scale consumes more RAM (cache both original size and resized size) but not faster for gpu-accelerated machines.

Also 2160px hight is too high. If you scaled images down under 50%, images gain aliasing. Too keep images clean, keep scaling factor 50% or higher.

User avatar
Ozitiho
Regular
Posts: 90
Joined: Mon Sep 22, 2014 3:29 pm
Location: Netherlands
Contact:

Re: Sprites look blurry when scaled using im.Scale

#3 Post by Ozitiho »

I see. Thanks, good to know. It's strange this isn't documented better in RenPy.

There has to be a way to support high resolution sprites though. I've seen VN games that look absolutely beautiful and crisp up to 4k and down to my laptop screen. Fault Milestone, to name one. I believe that one is even made in RenPy. I'm going to have to find a way to replicate that in my VN.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Sprites look blurry when scaled using im.Scale

#4 Post by Arowana »

Aliasing like this has been an issue for a while. RenPy only has bilinear interpolation (for now), which, like nyaatrap said, doesn't look good if you downscale too much.

I think what most people have been doing is to save two or three separate sprite sets at different sizes so you never have to downscale past 75% or so, similar to what the OP ended up doing here. It's a bit of a pain and takes up more space, but I don't know if there's currently any better way around it. :(
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

User avatar
Ozitiho
Regular
Posts: 90
Joined: Mon Sep 22, 2014 3:29 pm
Location: Netherlands
Contact:

Re: Sprites look blurry when scaled using im.Scale

#5 Post by Ozitiho »

Yeah, I've heard that it's been a thing since forever... Honestly I'd be fine with exporting lower resolution sprites. Filesize is only a very minor concern compared to fidelity and the resizing proces can be automated. But if I do end up doing that, I'll need to somehow dynamically reload all sprites every time the user resizes the window. I'm not sure how to do that yet, though I'm sure I can find out.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], BlueStylus