Enforce virtual resolution for a transform with 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.
Post Reply
Message
Author
morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Enforce virtual resolution for a transform with scaling?

#1 Post by morganw »

Hi!

I'm working on something similar to this where I'm using a very low resolution and letting it scale up based on the drawable resolution.

Code: Select all

config.screen_width = 320
config.screen_height = 180
config.nearest_neighbor = True
This is working great except that attempting to scale pixel art with a transform results in a displayable being rendered in the drawable resolution (pixels in the image are displayed at co-ordinates that don't exist in the virtual resolution) rather than being aligned to the virtual resolution defined in the config. It only seems to be scaling that is affected, transforming the position will always give alignment to the virtual resolution.

If I scale the image with im.Scale it returns the correct result for the virtual resolution (presumably this is being scaled by the CPU rather than the GPU?).

Is there any way to enforce the virtual resolution for a transform that includes scaling, so that pixels in displayables are always aligned and of a consistent size?

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: Enforce virtual resolution for a transform with scaling?

#2 Post by PyTom »

I think you probably want:

Code: Select all

define config.use_drawable_resolution = False
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

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Enforce virtual resolution for a transform with scaling?

#3 Post by morganw »

Thanks for the reply.

I've tried this but it seems to trigger a bug where mouse co-ordinates are no longer aligned with image co-ordinates. Now the game isn't scaled to fill the window or go fullscreen, but the mouse co-ordinates are.

I've captured what it looks like here:
https://www.dropbox.com/s/ygsi6fkpgxjgj ... roblem.gif

Also I was using config.adjust_view_size to lock to integer scaling, but now this is actually increasing virtual resolution (backgrounds that should be scrollable are now displayed in full once the windows size is big enough).

Should I file a bug report somewhere?
I see this has been opened. Thank you.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Enforce virtual resolution for a transform with scaling?

#4 Post by morganw »

I've tested the nightly build with the fix. The final scaling now matches the mouse position and fixes the use of the scaling multiplier but

Code: Select all

config.use_drawable_resolution = False
doesn't seem to have any effect on the transform. It's definitely on because text rendering for graphical exception handling is now forced to the virtual resolution.

Is this a separate bug or does config.use_drawable_resolution not actually affect a transform?

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: Enforce virtual resolution for a transform with scaling?

#5 Post by PyTom »

It should affect everything. Can you put together a replication, that points out what's wrong? Once I have that, I can try to debug the problem.
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

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Enforce virtual resolution for a transform with scaling?

#6 Post by morganw »

I've made a replication, here is the download link:
https://www.dropbox.com/s/mpgdzzptl4mj5 ... n.zip?dl=1

It shows:
  • the original image
    the same image scaled with im.FactorScale
    the same image scaled with im.FactorScale (bilinear filtering disabled)
    the same image scaled with a transform
The final image (the one scaled with a transform) is displayed in the drawable resolution.

Here is a screenshot of the result:
https://www.dropbox.com/s/on4r5y46s7swa34/result.PNG

Thanks for looking at this.

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: Enforce virtual resolution for a transform with scaling?

#7 Post by PyTom »

Thank you. Your issue number is 793. https://github.com/renpy/renpy/issues/793
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
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: Enforce virtual resolution for a transform with scaling?

#8 Post by PyTom »

Okay, I see what you're seeing, but I don't think this is something I want to fix. To do so, we'd have to propagate information about the virtual resolution down to the shader and even the texture coordinate level. That would be a ton of work, and it would likely slow down games that didn't use nearest neighbor.

I just can't see putting that much work into supporting pixel art games, especially ones that are unfaithful to the originals (by using Ren'Py to scale their images rather than using prescaled sprites). I don't like saying I won't support something, but I can't see adding a huge layering violation to make this work.

(Thank you for making the replication. Without seeing it, it was hard to understand exactly what was wanted.)
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

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Enforce virtual resolution for a transform with scaling?

#9 Post by morganw »

Okay, thank you anyway. I appreciate your time in looking at this as well as the fast response.

I'm using Creator-Defined Displayables so I think I'll try to optionally create scaled versions with im.Scale as part of the __init__ method (when scaling is required), and switch between these images when I need something to appear to be scaled.

Post Reply

Who is online

Users browsing this forum: No registered users