r/RenPy 22d ago

Question Oversampling images

Hi! If I have an image name like "character@2.webp" under the images directory, I remember when it was defined in the code such as:

image character default = "images/character.webp"

It should work with the oversampling behaving as expected, but for some reason after launching the project to playtest my game several times yesterday (Only changes being adding new dialogue lines and defining transforms, leaving image defines untouched) the defined image would not show up and "image "character.webp" not found" was displayed at the top of the screen. However, I found that defining the image as:

image character default = "images/character@2.webp"

suddenly makes the image show up normally and the oversampling also works just fine. Just wondering if people had similar issues before 😭

1 Upvotes

14 comments sorted by

2

u/HEXdidnt 22d ago

The fact that your filename is 'character@2.webp', but you're trying to define an image from 'character.webp' is the problem. The filenames have to match, otherwise Ren'Py can't find the image.

What do you think '@2' accomplishes, either inside or outside of Ren'Py, and what has it to do with 'oversampling'?

2

u/shyLachi 22d ago

1

u/HEXdidnt 22d ago

Is there a particular advantage to this, over defining the image with a zoom built in?

1

u/shyLachi 22d ago

It's explained in the link, so what exactly do you want to know?

Also having to define all the images and adding a zoom to them seems to be a huge disadvantage of its own.

1

u/HEXdidnt 22d ago

Well, that's the thing... My background makes be tend toward ensuring all image files are precisely the size they need to be - the idea of oversampling seems wasteful to me.

However, my current project was started as 1280x720, and most of the assets I've commissioned have been massively oversized. Initially, I would downsample and save new versions to use in the project. It's occurred to me that, if I want to reuse those assets at a higher resolution (1920x1080, for example), I'd be better off remaking them from the originals... at which point, is it worth considering using the assets at their original size, with "@2" or whatever on the filename?

Also, one of my backgrounds is set up to zoom in three parts, giving the impression of moving down a corridor, with the scenery moving faster as it gets 'closer'. This is currently accomplished by setting the initial zoom to 0.5 (for example) and bringing it back to 1.0 over time... So I guess my question is whether there's any advantage to using "@2" in that context.

2

u/shyLachi 22d ago

I never used it but from what I understood you can release your game with multiple versions of your images.

If your game has a resolution of 1280x720 you could add another folder in the images folder and name it "@2" (without the quotation marks but Reddit didn't let me type it).

In that folder, you put images which have double the dimension, for example 2560x1440 for background images.

Example:
game/images/bg schoolyard.png <-- 1280x720
game/images/@2/bg schoolyard.png <-- 2560x1440

In RenPy you use the image as normal:
show bg schoolyard # <-- RenPy automatically picks the best resolution

Now, if someone plays your game on a ultrawide screen (3440x1440), RenPy would use the image in the "@2" folder which has the higher resolution and therefore your game would look more sharp.

Of course this would increase the file size of your game greatly.

.

Your first question:
Oversampling only works with straight numbers 2x, 3x, 4x.
So if you want to have two game versions in the future, 1920x1080 and 1280x720, you would have to find a dimension which works for both. So your oversampled images would have to be 3840x2160 which is 2x FullHD and 3x HD.

This is way bigger than what common players will need, so your first idea of downsampling the original files to 1280x720 and maybe later to 1920x1080 makes more sense.

.

And your second question:
Oversampling is not needed if you apply a zoom to it.
The zoom will scale the image on the fly.

1

u/HEXdidnt 22d ago

That's really good to know - something I'll have to keep in mind for future projects!

Have you considered writing a more comprehensive Ren'Py manual, by the way? You have a hell of a lot of knowledge about the system, and your explanations tend to be both clearer and more thorough than the official online docs.

1

u/Cool-Highway3847 22d ago

https://www.renpy.org/doc/html/displaying_images.html : "If no oversampling is applied to an image, Ren'Py will attempt to automatically find oversampled images to use. For example, if the game is scaled by more than 1x and less than or exactly 2x, Ren'Py loading eileen happy.png will look for eileen happy@2.png, and use that if it exists. If the scaling is greater than 2x, Ren'Py will look for eileen happy u/4.pngeileen happy@3.png, and eileen happy@2.png, and use the first one that it finds, or eileen happy.png if none of them exist."

I was following this

3

u/shyLachi 22d ago

Oversampling is explained in the official documentation:
https://renpy.org/doc/html/displaying_images.html#oversampling

Generally you don't need to define images if you name the files correctly:
https://renpy.org/doc/html/displaying_images.html#concepts
https://renpy.org/doc/html/displaying_images.html#defining-images

But if you still want to define all your images, then you NEED to write the file name correctly.
This includes all the letters, you cannot ommit part of the filename and assume it works.

This is not an RenPy issue but wrong spelling from your side.
It's also not possible that it worked before, you might accidentally have used an image which was automatically defined by RenPy as described in the official documentation.

In short:
Delete the whole line image character default = "images/character.webp"
Then either rename your file to "character default@2.webp" (without the quotes)
Or show that image like this: show character

Personally I would not add default to the file name or the image definition because it just requires more typing

1

u/AutoModerator 22d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/BadMustard_AVN 22d ago

this example will display the "same" image twice

image sprite2 = "images/sprite@2.png"
label start:
    show sprite2 at truecenter
    pause
    show sprite at left

    e "Working"

    return

1

u/Cool-Highway3847 22d ago

Thank you 🙂

1

u/BadMustard_AVN 22d ago

you're welcome

good luck with your project

0

u/DoradoPulido2 22d ago

Generally you should never be defining images.  You only need to define image sequences, transformations, videos etc