LR2 Image Drawing Optimization
Added 2020-06-11 09:48:09 +0000 UTCLast update cycle I took some time to look at the way images were displayed and profile what was taking up the bulk of the time. I had expected the bulk of the time to be taken up by the animation system having to convert the displayable into a flat .png, but the answer was more complex than that. The conversion was inefficient, but it was taking up closer to 50% of the time needed to display rather than dominating the process. Additionally, I was noticing a strong correlation between the complexity of a girls outfit and how long it was taking to display, both with and without animation. Now you can say you're giving your girls skimpy uniforms for performance reasons!
I've been thinking about this for a while, but a comment from a patron finally kicked me off in the right direction. All of the images for LR2 are cropped to a specific size based on the position they are for (standing, sitting, doggy, etc). For many images this results in a lot of empty space but it makes layering the images trivial. For a long time I didn't think this would be a problem: the actual image files are tiny. My patron noted that they will only be tiny when they are compressed, when a 500x1080 pixel image is uncompressed by Ren'py to be it's going to take the same amount of space regardless of what it contains. Just as importantly, any operations I perform on that stack of images (like applying an alpha mask to hide or colour sections of it) will involve a lot of calculations for sections of the image that are blank.
The fix for this is simple, at least as a concept. If I crop all of the clothing items images to their bounding box I remove the bulk of the empty space from most images (patterns, jewellery, makeup, and skimpy lingerie especially). To properly align the cropped images I will need to keep track of their new offset and apply that shift when they are put into a compound image. In practice this will require some new script writing for GIMP to find the bounding box for each clothing item and to crop it to that item. The code inside of Lab Rats 2 will require very few alterations and should hopefully run significantly faster.
Comments
The core of LR2 is genius game design. It's a sandbox with huge potential for users to craft their own experience. Fans of LR2 keep asking for more attractive models and better hair styles. As for animations, I will always turn them off. Thank you for adding pregnancy. Keep up the great work.
2020-06-13 02:59:24 +0000 UTCHey Vren, thanks for the pregnancy content, it's good so far! While you are working on the image optimization, I was wondering if I could request finger /toe nail paint as an optional accessory. This would open up a ton of customization! Thanks!
2020-06-12 17:02:19 +0000 UTCI'm glad to see this is being optimized, it has felt like the game has been getting slower/laggy with each update and affected my enjoyment of the game. Thank you :)
SomebodyElse
2020-06-12 11:07:43 +0000 UTCI was thinking the images got slower. Might be my old computer not able to multithread. Sine note: girl not shown during pregnancy announcement scene.
Robert McClenahan
2020-06-12 04:01:58 +0000 UTCSomewhat tangentially related to clothing - I've noticed that if you give the girls a work uniform (full outfit) such as an evening dress, and no underwear, they react in some cases as if they're naked (for example, you can't tell them to strip, and the first time you see them in the dress they'll give you the "uncomfortable with your seeing them" responses, and the taboos will be lifted) and in some cases not (they'll still ask to strip it off during sex). I'm not sure why wearing an evening dress "commando" is considered nudity, but it should at least be consistent there. Similar issues exist with things like crotchless panties and pasties - they won't take those off if you command them to strip naked but they will during sex.
GAZZA
2020-06-12 02:09:03 +0000 UTCHowever, as it can be seen, sometimes comments from patrons give considerable results. Thanks to him for the help)
VitAnyaNaked
2020-06-11 22:22:12 +0000 UTCI'm curious is maintaining a complete history of all decisions (for rollback) also contributes to the slowness thought that game that isn't image related...
Yellowcake Uranium
2020-06-11 10:41:57 +0000 UTC