Masking and speed

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
monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Masking and speed

#1 Post by monele »

A few questions to know how I could handle a little something in my project :

I suppose having a scrolling 800x300 picture is better than a 800x600 one :)

Let's say this picture is centered on the screen surrounded by black. I suppose that it's also faster not to have any Solid(0,0,0,255) scene (no scene = black background anyway, right ?). The only problem would be the screen refreshing (the dialog box wouldn't be refreshed properly according to my tests).

Image

So ok, I have a black scene, and the 800x300 scrolling band in the middle... Now I want something taller than 300 pixels displayed *only* in the scrolling zone, not over the black borders (movie like if you will).

Image Image

Is there a way to mask blitting only to that specific zone (and would it be better than...) or should I blit two black borders over all this myself ?

Considering there's no masking and I blit the black borders... is the engine optimized to not blit everything under the opaque border since they're not seen anyway ?

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:

#2 Post by PyTom »

You have to blit the black borders on top of the image, and this case isn't optimized in the current Ren'Py. (Well, blitting the mask image is optimized, but clipping the non-mask image isn't.)
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:

#3 Post by DaFool »

monele, you stole my idea! :shock:

Just kidding 8)

Seriously, I'm doing everything in widescreen (less picture size, less work, correct :P )

I have here two examples. First example is background panning up in widescreen. Second example is character (who is drawn full-bodied but has to be cut off in widescreen) changing postures without popping out of the scene. In both cases I have to make sure the whole scene is continually covered by 'widescreen filtermode' which is essentially 2 black bars top and bottom with transparency in the middle. Not exactly what you're looking for, but hope this technique helps. I just happen to be using 4:3 backgrounds, but since you mention the default background is black, for static scenes I might as well resize the bgs to widescreen proportions to save on filesize.

1.)
#backgrounds 800x600
image bg cubao day = "CubaoDay.jpg"
image bg vigan day ="ViganDay.jpg"
#characters
image widescreen filtermode = "widescreenfilter.png"
image melinda straight = "melinda1.png"
image melinda bend = "melinda2.png"

label start:

scene bg cubao day at Pan((0, 100), (0, 0), 3.0)
show widescreen filtermode
"What will it be today?"

2.)
scene bg vigan day
show melinda straight
show widescreen filtermode
"Let me tell you my story."
hide widescreen filtermode
hide melinda straight
show melinda bend
show widescreen filtermode
"Listen Up."

I sincerely hope after I release my project, more people will be doing things in widescreen. I'm doing 2.35:1 with the upper black bar smaller than the bottom one, that way the text will fit nicely as subtitles.

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#4 Post by monele »

I don't think we're using widescreen for the same reasons though ^^. I'm just trying to optimize future animations by displaying less of them, in the hope that it will be faster. But if I have to blit over them, it won't :/. I'd also like to be able to display little things in comics-like frames (where I *can't* blit things all around, since it's supposed to be see-through ^^;...)

PyTom : I know I'm still asking for crazy things but can I know how difficult it would be to be able to set a drawable portion of the screen at some point so that all further blitting is confined to this part until you reset it ? (since that would improve speed... right ? :/)

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:

#5 Post by PyTom »

I'll look into it.

One idea would be the ability to define layers as a sub-area of the screen, and all drawing to a particular layer would be confined to that area of the screen. (So one could have a letterboxed master layer, for example.)

We'll see what happens.
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
mikey
Lemma-Class Veteran
Posts: 3249
Joined: Sat Jan 10, 2004 6:03 am
itch: atpprojects
Contact:

#6 Post by mikey »

DaFool wrote:Seriously, I'm doing everything in widescreen (less picture size, less work, correct :P )
Less picture size... isn't it better to make your game with lower res? Like 640x480 8) I know people usually encourage 800x600, but at the end if less resources are what you're aiming at, it can be a better option than going with 800x600 and having the style of view that was usually experienced from a medieval crusader's helm.
Of course I'm just saying this because all my games are 640x480 ^_^

shaja
Regular
Posts: 73
Joined: Sun Oct 16, 2005 8:34 am
Contact:

#7 Post by shaja »

I prefer higher game resolutions for crisper text rendering.

In some sort of ideal VN world, the displayables would be hardware scaled from whatever resolution they were authored at to the nice, high resolution of my monitor, with the game text being rendered natively at that resolution.

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

#8 Post by DaFool »

640 x 272 it is then!

The Narcissu level of minimalism is killing me :D

But actually originally it isn't minimalism but maximalism which is driving this. I like pumping out lots of backgrounds and character poses, and seriously need a way to do it fast. Since I'm also going to have lots of bells and whistles, I want the program to play smoothly. It's similar to Flash...have you seen .swfs? They're vector so don't really have a resolution, but when you expand the window, unless you have a nice machine, the slowness that results is severely disappointing.

I don't want that. I want a kinetic novel after all. Think of like video. When paused, its obviously low-res than what you use for your wallpaper. But in motion, it looks gorgeous. That's the look I'm trying to achieve.

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#9 Post by monele »

Hmm, we might be looking for something quite similar after all :).

PyTom : your idea sounds great, since it means we could easily display the masked zone above any other without worrying about defining sizes all the time... and maybe it could even avoid multiple scene+show+show+show statements for the lower layers ? In any case, thanks ^.^

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

#10 Post by DaFool »

I think I may have found a bug after playing with 640X480 resolutions...

I'm just using a default / empty script where its just black screens:

$ config.screen_width = 640
$ config.screen_height = 480

When I start the game, then use right-click, the save slots fall on top of the "Return" and "Begin Skipping" options. The only options not covered by the save slots are "Preferences" and below.

This does not happen with 800X600 since the text font is smaller.

Ideas?

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:

#11 Post by PyTom »

Add a $ theme.roundrect() line after those, as the roundrect theme auto-adjust to 640x480.
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

Watercolorheart
Eileen-Class Veteran
Posts: 1314
Joined: Mon Sep 19, 2005 2:15 am
Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
Organization: Watercolorheart Studios
IRC Nick: BCS
Tumblr: adminwatercolor
Deviantart: itsmywatercolorheart
Github: Watercolordevdev
Skype: heartnotes
Soundcloud: Watercollider
itch: watercolorheart
Location: Florida
Contact:

#12 Post by Watercolorheart »

Remember back when I was doing games for the 1000xwhatever resolution? XD

Although, I will always prefer 800x600 because my actual dimensions for my desktop are always 1200xsomething ... and I do full-screen.

Full-screen looks crappy with the 600xsomething dimension (I can't even remember the exact dimensions because I never use them ...) but I did think that Narcissu looked okay.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#13 Post by Jake »

monele wrote:PyTom : I know I'm still asking for crazy things but can I know how difficult it would be to be able to set a drawable portion of the screen at some point so that all further blitting is confined to this part until you reset it ? (since that would improve speed... right ? :/)
I was thinking how nice something a bit like this would be myself, a couple of days ago... but the thing I was after was a way to define alpha masks for a UI element that would 'contain' all the elements within them. Were such a thing available I could have, say, an rounded-rectangle image for a frame, and then have a similar rounded-rectangle mask, then if I drew anything inside the ui element which had that frame, whatever the padding settings it would get masked to fit within the graphical representation of that frame.

As far as graphics programming goes, I'm pretty sure it's not significantly different from recolouring and then blitting an image... but obviously that heavily depends on the order you draw things in, and the libraries you're using. ;-)

Realistically, if I were making a game I could just pre-cut my resources to fit whatever frame I was using, although it might lead to duplicate graphics in the package... it occurred to me while I was playing with themes. It'd be really cool to be able to have, say, ornamental wrought-iron or flowery corners to the inside of frames laid into the alpha values for whatever they happened to be displaying...
Server error: user 'Jake' not found

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:

#14 Post by PyTom »

Well, if you want a frame over your text, you can always do something like:

Code: Select all

init:
    $ config.layers = [ 'master', 'frames', 'transient', 'overlay' ]
    image myframe = "myframe.png"

label start:
    scene myframe onlayer frames

    ...
And all images will be shown underneath the myframe image. This isn't masking, but can often accomplish the same effect, and is quite efficient, as SDL/pygame (and therefore Ren'Py) can optimize long runs of transparency.
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

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#15 Post by monele »

Realistically, if I were making a game I could just pre-cut my resources to fit whatever frame I was using, although it might lead to duplicate graphics in the package...
And if you want to make things move inside the frame... you can't just precut things ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot]