[Solved] Pixel perfect upscaling
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.
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.
[Solved] Pixel perfect upscaling
My game uses a 640x480 resolution. Problem is, it is a resolution that if you have a standard 1080 screen, it will be in a tiny window, and if you go on fullscreen, it will be not pixel perfect, meaning it will have some sort of antialiasing which doesn't really good great. I wonder how I could Implement a option to make it run in a 2 times bigger window and/or a fullscreen version that makes the image 2 times as big and puts black bars.
I got the idea from the game "Needy Girl Overdose" which does the same, but it runs in unity.
I got the idea from the game "Needy Girl Overdose" which does the same, but it runs in unity.
Last edited by simba975 on Sat Feb 10, 2024 5:36 am, edited 1 time in total.
- m_from_space
- Eileen-Class Veteran
- Posts: 1011
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Pixel perfect upscaling
Renpy supports all of this, black bars are added if the window/full screen ratio doesn't match the game's ratio.
I'm not sure what you are asking here, because if you increase the size of the window, the images will increase as well. If you talk about upscaling low resolution images to 2x bigger images with same quality, then remember that's not possible. Unless you like upscaled images using A.I., which certainly won't look super great.
What is not "pixel perfect" in your case? If you use absolut positions inside the screen, then things should work. If you use relative positions like "xpos 0.5" or "xalign 0.2", then rounding errors will occur I guess.
Re: Pixel perfect upscaling
I mean "pixel perfect" in the pixel-art kind of way. I want to upscale in full intervals like 2 because that way each part of the image that previously used 1 pixel now will use 4, making it so the screen doesn't has to go with making the intermediate of 2 pixels. The problem is that 480 and 1080 are in a proportion of 1:2.25, which means that It can't be pixel perfect, and for example if there is an image that has completely white and completely black lines, if you upscale it a resolution that has a proportion with decimals, it will result in the pixels between the black and white lines to be grey, because a pixel is between two colors and instead of picking one of them makes an average of the two. That's why I want to make a preset of "x2 size", so the screen doesn't average between two pixels and it manages to get a "pixel perfect" look.
In this case if I wanted It to look correctly, the window size should be exactly 1280x960, no more no less.
Edit: investigating, it seems like "config.physical_width" and "config.physical_high" is exactly what I need, but I can't seem to make it work. I tried with "define config.physical_width = 1280" and "init python: config.physical_width = 1280" but it desn't do anything.
In this case if I wanted It to look correctly, the window size should be exactly 1280x960, no more no less.
Edit: investigating, it seems like "config.physical_width" and "config.physical_high" is exactly what I need, but I can't seem to make it work. I tried with "define config.physical_width = 1280" and "init python: config.physical_width = 1280" but it desn't do anything.
- m_from_space
- Eileen-Class Veteran
- Posts: 1011
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Pixel perfect upscaling
Ah I see. So it seem you just might want to set the following. This defines the upscaling method.
Code: Select all
define config.nearest_neighbor = True
Re: Pixel perfect upscaling
Thank you, define config.nearest_neighbor = True works really well, tho I would still want to know if I can do a x2 upscale since nearest neighbor can always get the exact proportion of things wrong, I will keep searching.
- m_from_space
- Eileen-Class Veteran
- Posts: 1011
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Pixel perfect upscaling
You can change the screen size yourself using the preferences while running Renpy.
Code: Select all
$ renpy.set_physical_size((1280, 960))
Code: Select all
label after_load:
if not preferences.fullscreen and renpy.get_physical_size() != (1280, 720):
$ renpy.set_physical_size((1280, 720))
Re: Pixel perfect upscaling
Yes I found that, I also found this:
which I put on my preferences so people can manually select it.
Now I just wonder tho, is there any way I can get something like this but running fullscreen instead of windowed? I mean the same size (1280, 960) but with the black bars that come with fullscreen, so that players don't get distracted with things in the background while enjoying a pixel-perfect experience.
Code: Select all
textbutton _("x2") action Preference("display", 2.0)
Now I just wonder tho, is there any way I can get something like this but running fullscreen instead of windowed? I mean the same size (1280, 960) but with the black bars that come with fullscreen, so that players don't get distracted with things in the background while enjoying a pixel-perfect experience.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Pixel perfect upscaling
Take a look at config.adjust_view_size. There's an example there in the documentation of how to force integer scaling, which can ensure that your game window is an integer multiple of the game size. (So it could be 1x, 2x, 3x, etc, but not between.)
Ren'Py will add a black (by default) border around the game to enforce this.
Ren'Py will add a black (by default) border around the game to enforce this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]