Automatic Scaling

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.
Message
Author
Florian

Automatic Scaling

#1 Post by Florian »

Hello everyone,

we are currrently creating a game in ren'py. We already created all content and the ren'py script. There's only one little problem left: All our images are in HD resolution (1920x1080) and we want to display them in the best possible resolution.

As far as I know, ren'py can't scale images automatically to the current resolution of the user. If I'm wrong there, please correct me since it would make things muuuuch easier. :)

So I had the idea to make the options-script query the current resolution of the user and set the game-resolution accordingly. Then I would scale the images in the script to this resolution (using im.Scale).

This plan has one weakness: Querying the resolution seems to be difficult. I found one way (described here), but this requires the GetSystemMetrics function from the win32api module. Unfortunately, this module doesn't seem to be included in ren'py.

Does anyone know how I can include the missing module?

Or does anyone know a better way? Maybe even one that is system-independent?

Greetings,
Florian

P.S.: Despite of this little problem: Thanks a lot for the great authoring system, PyTom. :)

User avatar
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: Automatic Scaling

#2 Post by PyTom »

I don't think this is a particularly good idea. Realize that the amount of work that Ren'Py has to do to show an image is roughly proportional to the number of pixels shown, and you're talking about quadrupling the size of images... that's going to lead to a significant slowdown.

Then there's the image cache... the image cache size is set based on the size of the screen. Loading such large pictures in would tend to blow out the image cache, leading to reduced performance.

I'd suggest sticking with some of the standard image sizes, like 800x600 or 1024x768. The latter seems to be bigger then most commercial games use.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Automatic Scaling

#3 Post by DaFool »

I have a feeling he is coming from a western commercial game perspective, not a Japanese one. (There seems to be a few recent posts from professional developers recently, a sign of things to come probably.) So perhaps the game was made for multiple platforms, including perhaps Xbox 360 or PS3. If you think about your average western PC game, you are able to set the pixel resolution according to your hardware. But of course, those were mostly real-time renders.

Florian

Re: Automatic Scaling

#4 Post by Florian »

PyTom wrote:I don't think this is a particularly good idea. Realize that the amount of work that Ren'Py has to do to show an image is roughly proportional to the number of pixels shown, and you're talking about quadrupling the size of images... that's going to lead to a significant slowdown.

Then there's the image cache... the image cache size is set based on the size of the screen. Loading such large pictures in would tend to blow out the image cache, leading to reduced performance.
These performance problems would only occur on high resolutions. I think if someone has an screen that is capable of displaying a resolution 1920x1080, there will probably be a fast computer connected to it.

I just did a quick test and used full res images on my 1280x800 resolution (the highest possible resolution of my laptop) and didn't notice any performance problem. And I don't have a notably fast computer.


@DaFool: Thanks for the compliment, but we are not professional developers. :)

User avatar
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: Automatic Scaling

#5 Post by PyTom »

Well, you can get a list of modes by running the following python code:

Code: Select all

import pygame
pygame.display.init()
modes = pygame.display.list_modes()
So there's no need to include win32 specific modules... which is good, since the win32 stuff is fairly large.

Probably the best way to do this is to modify renpy/display/scale.rpy. You'd want to add code into that file that scans for video modes, picks a mode, and then computes an appropriate scaling factor. You'd then go and set factor to that scaling factor, and the automatic scaling (imouto) mode kicks in, and you're all set.

A benefit to this is that the automatic scaling mode lets you write the game as if it was a 1920x1080 game, and automatically translates positions and the like. Imouto-mode also properly deals with cache behavior, so you won't totally break the cache.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

Re: Automatic Scaling

#6 Post by Criptych »

Just curious, how did automatic-scaling mode get the nickname "imouto"?
Computers are useless. They can only give you answers. —Pablo Picasso

Image

c.s.marshall
Newbie
Posts: 18
Joined: Wed Apr 11, 2007 2:44 pm
Location: Dortmund, Germany
Contact:

Re: Automatic Scaling

#7 Post by c.s.marshall »

The last time I checked, Ren'Py was intended to create VN's - or did I misread something?

Really, I have until now to find *one* example of a game that would require such high resolution especially when many (if not most) people use smaller resolutions. The question itself is a contradiction in terms as
"1920x1080" is the only resolution capable of displaying all the information - everything else is just "fiddling around" to make it fit.

For example a rescaled 1280x1024 pic on a CRT looks different on a TFT and vice versa, not even thinking of 32 or 24 bit, etc. - so a downscaled picture will nearly always look crappy (higher downscale = more crappy result). The question is: do you want to risk a bad rating for a game? Because the comment "but it IS better in 1920x1080" goes TOTALLY unnoticed as the critics (that near always use standard res) see downscaled graphics - and treat the game accordingly, no matter what you claim to be the 'normal' resolution.

USERS set the 'standard' they want to use, not you. The heavy duty game industry learned that lesson a while back: the user likes good games, but not for the price of absolutely hogging down the system or having to install two DVDs for a game that otherwise fits on a CD. Look at the people that 'digged' all the nice console games because the resolutions were "CRAZY, MAN!" ... and then only played them while hooked up to a standard TV ;-)

---
The next question will probably be how one can limit Ren'Py to display at a minimum of "x" frames per second because it's "kewl" to have high FPS ... gheeez ;-)
---
Chris

User avatar
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: Automatic Scaling

#8 Post by PyTom »

Criptych wrote:Just curious, how did automatic-scaling mode get the nickname "imouto"?
Hm... since there characters are smaller, they're the little sister of regular-sized characters.

Hey, you try going for a Ph.D. and remaining sane throughout the process.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Free Time Machine
Regular
Posts: 42
Joined: Fri Jun 15, 2007 9:45 am
Location: Philly, USA
Contact:

Re: Automatic Scaling

#9 Post by Free Time Machine »

Hey, you try going for a Ph.D. and remaining sane throughout the process.
Kids all around me are losing it over their bachelor's degrees. Those who make it to the PhD process before starting to unravel have significant stamina in my book.
"HOLD ON TIGHT" ~ Outfits and expressions, where art thou? And why does Elsa's face look so awful??? *bangs head in*

Everytime you delete a traceback, someone else gets it. -PyTom

Dennis
Newbie
Posts: 11
Joined: Sun Jul 08, 2007 4:37 pm
Location: Esslingen, Germany
Contact:

Re: Automatic Scaling

#10 Post by Dennis »

Dear PyTom et al,

I'm on the project with Florian. Thanks a lot for your help with automatic scaling, it's working fine :) The code we included in scale.py was:

Code: Select all

import pygame
pygame.display.init()
modes = pygame.display.list_modes()

if (modes[0][0] >= 1920):
    factor = 1
else:
    factor = modes[0][0] / 1920.0
Two minor issues, any help would be appreciated!

1. By setting a very high resolution and automatically scaling it down to fit the reader's screen, I had to adapt the size of the GUI. Basically, I increased font size from 22 to 44. On a standard resolution, it would then look like 22 again. For button size to suit the new font size, I gave them

Code: Select all

$ style.button.xminimum = 0.25
However, I did not get this to work with the three preferences columns. I did not manage to give anything an xminimum there. Any idea? Maybe I just missed something? As a workaround, I used a smaller font size

Code: Select all

$ style.prefs_label.size = 32
$ style.prefs_button_text.size = 32
as well as shorter words (the VN is in German so the GUI gets translated anyway). I'm still using Ren'Py 6.1.1. Yeah, shame on me, but since the story is quite long with lots of sounds etc, I thought 'never change a running system'.

2. and maybe more troublesome: With automatic scaling, screenshots taken for savegame thumbnails don't work anymore. When saving, Ren'Py just displays a black box next to the date, in the specified thumbnail size. I tried different sizes, but: always just black.

This I 'solved' (not really...) by not having thumbnails displayed - or actually very small ones:

Code: Select all

$ config.thumbnail_height = 2
$ config.thumbnail_width = 2
Any idea how I could have savegame thumnails with automatic scaling? Would be nice, the thumbnails are great :)

Thanks!

Dennis

User avatar
mikey
Lemma-Class Veteran
Posts: 3249
Joined: Sat Jan 10, 2004 6:03 am
itch: atpprojects
Contact:

Re: Automatic Scaling

#11 Post by mikey »

Hmmm, is this by any chance the "Felix, Gaijin" project? I read it was to be presented at a convention in late June and then released. I check everyday to find the relase, but it seems you want to make more tweaks before releasing it.

Dennis
Newbie
Posts: 11
Joined: Sun Jul 08, 2007 4:37 pm
Location: Esslingen, Germany
Contact:

Re: Automatic Scaling

#12 Post by Dennis »

Wow, our first fan, I'm flattered :)

Sorry for keeping you waiting. Yes, we presented "Felix, Gaijin" on 28th June. But then it still had some bugs and did not have the automatic scaling. Expect it to be downloadable at http://www.serik.de/felix by the end of the week :)

User avatar
mikey
Lemma-Class Veteran
Posts: 3249
Joined: Sat Jan 10, 2004 6:03 am
itch: atpprojects
Contact:

Re: Automatic Scaling

#13 Post by mikey »

That's good news! With Nettestadt Troll, that means we'll have two new VNs to play this week. :P

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Automatic Scaling

#14 Post by DaFool »

I hope my 4 years of German language will help me understand yours, at least.

LOL, July is the month for VNs set in Deutschland! :D

edit: well, German characters at least :oops: (And I notice a trend that Ren'Py VNs now are usually released batch of two in a single week per month.)

User avatar
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: Automatic Scaling

#15 Post by PyTom »

Hm... I think xminimum (and xmaximum) need to be an absolute number of pixels, not a relative size.

I'll look into the thumbnails issue.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot]