LiveComposites creating unexpected image loads

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
User avatar
moogsparfait
Regular
Posts: 53
Joined: Mon Apr 28, 2014 9:26 pm
Completed: Danmaku!! (Card Game)
Projects: The Parasol Festival
Organization: Mystery Parfait
Contact:

LiveComposites creating unexpected image loads

#1 Post by moogsparfait »

It seems like a common thing but I can't find a cookbook entry on this that isn't something I've tried. Maybe I'm searching for the wrong terms.

Anyway, I have a problem where I can't get my multilayered sprites to stop generating unexpected image loads, which I believe is screwing up my transitions.

You can see a couple of styles of sprites I've tried below, the first is an example provided by an embarrassed dev who requested not to be named. They all generate unexpected image loads though.

These sprite parts aren't declared, and I have a theory that would fix my issue, but I can't figure out how to make a composite of declared parts.

Code: Select all

init python:
### ANISE
    def draw_anise(st, at):
        return LiveComposite((358, 790),
        (0,0),  "sprites/anise/base.png",
        (0,0), ConditionSwitch(
            "an_emo == 'blush' ", "sprites/anise/emo_blush.png",
            "an_emo == 'blush2' ", "sprites/anise/emo_blush2.png",
            "True", Null(),
            ),
        (0,0), ConditionSwitch(
            "an_eyes == 'avert' ", "sprites/anise/eyes_avert.png",
            "an_eyes == 'clenched' ", "sprites/anise/eyes_clenched.png",
            "an_eyes == 'closed' ", "sprites/anise/eyes_closed.png",
            "an_eyes == 'derp' ", "sprites/anise/eyes_derp.png",
            "an_eyes == 'down' ", "sprites/anise/eyes_down.png",
            "an_eyes == 'jitome' ", "sprites/anise/eyes_jitome.png",
            "an_eyes == 'jitomeavert' ", "sprites/anise/eyes_jitomeavert.png",
            "an_eyes == 'narrow' ", "sprites/anise/eyes_narrow.png",
            "an_eyes == 'open' ", "sprites/anise/eyes_open.png",
            "an_eyes == 'shine' ", "sprites/anise/eyes_shine.png",
            "an_eyes == 'teary' ", "sprites/anise/eyes_teary.png",
            "an_eyes == 'tender' ", "sprites/anise/eyes_tender.png",
            "an_eyes == 'up' ", "sprites/anise/eyes_up.png",
            "an_eyes == 'wide' ", "sprites/anise/eyes_wide.png",
            "an_eyes == 'wideavert' ", "sprites/anise/eyes_wideavert.png",
            ),            
        (0,0), ConditionSwitch(
            "an_mouth == 'agape' ", "sprites/anise/mouth_agape.png",
            "an_mouth == 'closed' ", "sprites/anise/mouth_closed.png",
            "an_mouth == 'crooked' ", "sprites/anise/mouth_crooked.png",
            "an_mouth == 'eek' ", "sprites/anise/mouth_eek.png",
            "an_mouth == 'frown' ", "sprites/anise/mouth_frown.png",
            "an_mouth == 'grin' ", "sprites/anise/mouth_grin.png",
            "an_mouth == 'happy' ", "sprites/anise/mouth_happy.png",
            "an_mouth == 'low' ", "sprites/anise/mouth_low.png",
            "an_mouth == 'pout' ", "sprites/anise/mouth_pout.png",
            "an_mouth == 'quiver' ", "sprites/anise/mouth_quiver.png",
            "an_mouth == 'shout' ", "sprites/anise/mouth_shout.png",
            "an_mouth == 'small' ", "sprites/anise/mouth_small.png",
            "an_mouth == 'smile' ", "sprites/anise/mouth_smile.png",
            "an_mouth == 'wide' ", "sprites/anise/mouth_wide.png",
            ),      
        (0,0), ConditionSwitch(
            "an_brows == 'angry' ", "sprites/anise/brows_angry.png",
            "an_brows == 'angrylow' ", "sprites/anise/brows_angrylow.png",
            "an_brows == 'cocked' ", "sprites/anise/brows_cocked.png",
            "an_brows == 'oneup' ", "sprites/anise/brows_oneup.png",
            "an_brows == 'furrowed' ", "sprites/anise/brows_furrowed.png",
            "an_brows == 'neutral' ", "sprites/anise/brows_neutral.png",
            "an_brows == 'raised' ", "sprites/anise/brows_raised.png",
            "an_brows == 'raised2' ", "sprites/anise/brows_raised2.png",
            "an_brows == 'sad' ", "sprites/anise/brows_sad.png",
            "an_brows == 'sad2' ", "sprites/anise/brows_sad2.png",
            ),
        (0,0), ConditionSwitch(
            "an_emo == 'shadow' ", "sprites/anise/emo_shadow.png",
            "True", Null(),
            ),
        (0,0), ConditionSwitch(
            "an_acc == 'bunny' ", "sprites/anise/acc_bunny.png",
            "True", Null(),
            ),
        ), 0.1
        
    def draw_lynae(st, at):
        return LiveComposite((389, 775),
        (0,0), process("sprites/lynae/base.png"),
        (0,0), ConditionSwitch(
            "ly_eyes == 'open' ", blinkfun2("sprites/lynae/eyes_open.png", "sprites/lynae/eyes_narrow.png", "sprites/lynae/eyes_closed.png"),
            "True", "sprites/lynae/eyes_" + ly_eyes + ".png",
            ),
        (0,0), "sprites/lynae/brows_" + ly_brows + ".png",
        (0,0), "sprites/lynae/mouth_" + ly_mouth + ".png",
        (0,0), ConditionSwitch(
            "ly_emo == 'off'", Null(),
            "True", "sprites/lynae/emo_" + ly_emo + ".png",
            ),
        (0,0), ConditionSwitch(
            "ly_fox == True", process("sprites/lynae/etc_fox_ears.png"),
            "True", Null(),
            ),
        ), 0.1

### male ADULT

    def draw_adultm(st, at):
        return adult_male_live(am_dress, am_hair_color, am_hair_style, am_eyes, am_brows, am_mouth, am_moustache_style, am_beard_style)
        
    def adult_male_live(dress, hair_color, hair_style, eyes, brows, mouth, moustache_style, beard_style, flip_h=False):
        return LiveComposite((423, 850),
        (0,0), "sprites/customers/adult_male/adult_male_dress_lskin_" + dress + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_head_lskin_" + hair_color + "_" + hair_style + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_eyes_" + eyes + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_brow_" + brows + "_" + hair_color + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_mouth_" + mouth + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_moustache_" + moustache_style + "_" + hair_color + ".png",
        (0,0), "sprites/customers/adult_male/adult_male_beard_" + beard_style + "_" + hair_color + ".png",
        ), 0.1

init:
    image anise = DynamicDisplayable(draw_anise)
    image lynae = DynamicDisplayable(draw_lynae)
    image adultm = DynamicDisplayable(draw_adultm)

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: LiveComposites creating unexpected image loads

#2 Post by PyTom »

Can you tell me how to repeat this? I dont' see anything obviously wrong, which means I need to poke around further and see what's going on.
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
moogsparfait
Regular
Posts: 53
Joined: Mon Apr 28, 2014 9:26 pm
Completed: Danmaku!! (Card Game)
Projects: The Parasol Festival
Organization: Mystery Parfait
Contact:

Re: LiveComposites creating unexpected image loads

#3 Post by moogsparfait »

http://www.mysteryparfait.com/download/ ... -debug.zip

I've created a debug game, here on my computer (A Surface 3) the 3 adult male characters appear in the middle of the screen and continue to the left offscreen, when they're supposed to move from offscreen right to offscreen left. Here is the code for the scene:

Code: Select all

label debug:

    
    scene bg guildhall_day
    #show guildhall_day_reader
    show guildhall_day_gossips
    show guildhall_day_manwithpackage
    show guildhall_day_histronicgirl
    show guildhall_day_argument
    show guildhall_day_fronttrio
    hide main_menu
    with dissolve
    
    $ an_eyes = "open"
    $ an_mouth = "closed"
    $ an_brows = "furrowed"
    $ an_emo = "off"
        
    show anise:
        leftoffscreen
        linear 1 leftedge
        
    an "Testing"
    
    show merchantA:
        rightoffscreen
        linear 1.2 leftoffscreen
    show merchantB:
        rightoffscreen
        linear 1.4 leftoffscreen 
    show merchantC:
        rightoffscreen
        linear 1.0 leftoffscreen 
        
    an "I got ignored"

This one also has the source files included. sprites.rpy, sprites_generic.rpy, and scenes.rpy contain various image definitions that generate the pink text.

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: LiveComposites creating unexpected image loads

#4 Post by PyTom »

So, there were a couple of issues here.

The first is a bug in Ren'Py that was preventing DynamicDisplayables from being predicted. That'll be fixed in 6.18.2.

There's also a second issue. You're filling the screen with a number of images - 6 fullscreen images, as I count them. With a few more things in the image cache, this means that there's no room to fit the merchant sprites. I'd suggest turning images like guildhall_day_fronttrio into a LiveComposite. Something like:

Code: Select all

image guildhall_day_fronttrio = LiveComposite((1600, 900), (100, 200), "fronttrio.png")
Basically, you create a fullscreen LiveComposite, and then position a much smaller image inside them. The transparent bytes in the big image take up memory, which is what was killing us here.
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
moogsparfait
Regular
Posts: 53
Joined: Mon Apr 28, 2014 9:26 pm
Completed: Danmaku!! (Card Game)
Projects: The Parasol Festival
Organization: Mystery Parfait
Contact:

Re: LiveComposites creating unexpected image loads

#5 Post by moogsparfait »

Thank you for looking into this, Tom. I'll do as you suggest for the composite background. I'm curious as to what the difference is according to Ren'Py, if possible I'd like to have a very busy screen at times so I'm interested in the best way to do these types of things.

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: LiveComposites creating unexpected image loads

#6 Post by PyTom »

In memory usage? Itś proportional to the size of the images in pixels. A 1600x900 image is going to take more space than a smaller image, and all 1600x900 images take the same amount of space.
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
moogsparfait
Regular
Posts: 53
Joined: Mon Apr 28, 2014 9:26 pm
Completed: Danmaku!! (Card Game)
Projects: The Parasol Festival
Organization: Mystery Parfait
Contact:

Re: LiveComposites creating unexpected image loads

#7 Post by moogsparfait »

Ah. I didn't realize it was a straight memory issue. It sounded like Ren'Py had a limited number of images it could display at once without doing extra work, like some sort of caching mechanism.

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: LiveComposites creating unexpected image loads

#8 Post by PyTom »

Basically, Ren'Py limits the image cache by the number of pixels. The limit is config.screen_width * config.screen_height * config.image_cache_size pixels.

So in your (6.18.1-based case), you have 8 * 1600 * 900 pixels to play with. This means that you can have 8 fullscreen images, 16 half-screen images, 32 quarter-screen images, etc - or any mix. 6.18.2 doubles the size of 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

Post Reply

Who is online

Users browsing this forum: No registered users