CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Ren'Py How to change character shape?

Firebian

Newbie
Nov 2, 2020
18
10
I'm learning how to make games in renpy and I saw this game here: Public Sex Life H
https://f95zone.to/threads/public-sex-life-h-v0-85-5-paradicezone.51860/

I saw something really interesting, which is several identical scenes, but with the character wearing different clothes, etc.
I wanted to do this, but the only way I found was to literally play and save, having several video or image files. This would generate a very large game with little story...
I was even thinking about migrating to Unity/Unreal exactly for this reason, to make a game where I can change the character and run the same scene, processing in real time.

Do you know of any way, through renpy, to have a scene rendered in real time and not need to have several images?
What do you think, know, suggest?

I didn't find any topic talking about this, but if there is, I would like to read it
Good morning everyone
 

Sukurumanu

New Member
Feb 13, 2024
4
0
Simple answer is 'No'. I don't think you should bend the engine to do something that it was not created for. If you really want to go that route, use Unity and Unreal.

That said, I have to thank you for that question. It forced me to look into it a bit more.

See, I'm right now making RenPy game and I'm facing similar set of problems as you do. I'm not crazy enough to think in the scale of multiple characters with multiple customization - I'd never finish the game. But I'm big Blender geek and hate controls of StudioNeo/HS - therefor it is painful for me to imagine preparing whole scenes in StudioNeo... My solution? Setup cameras/light as close as possible to each other in blender and StudioNeo, render scene in Blender and render character (even animated in StudioNeo). (And yes, I know it is possible to migrate characters from studio neo to Blender, but IMO no one sane would do it on scale. :))

So result? I export animated characters with transparent backgrounds and place it over blender rendered backgrounds in RenPy. (see result in attachment) Playing animation using simple ATV in RenPy. Something like:

Python:
init python:

    frames_crystal_idle = []

    for i in range(149):

        frame_name = f"images/animations/crystal/idle/{i:03d}.png"

        frames_crystal_idle.append(frame_name)

        frames_crystal_idle.append(0.125)


image a_crystal_idle = Animation(*frames_crystal_idle)

Now, this animation is 60fps, 10seconds long. 960x1080. Used in conversations. Size of mp4 is 2,2MB. (see attachment) Size of 600frames in PNG format is whooping 351MB. What I did is that I simple reduced FPS, right - no brainer - no need to go 60fps for conversation idle animation. If you go down to 8fps, it will be a bit clunky, but not bad and animation will take 42MB.

And here comes a realization I had when I thought about your question.
First - can I make transparent video? Answer - no and yes. I can make video with green background and then dig deep into RenPy shaders and OpenGL's GLSL and plug it together with rendered Blender background. Too much work and again - bending RenPy to do something it is really not used to.

Second - what if i don't use PNG and go with webp instead? RenPy since 7.4 supports it natively. Answer - YES. Just converting those 600 PNGs into webp with 80 quality resulted in 18,2MB sized set of images! 60fps! (PNG and WebP variants in attachment for comparison)

You do realize how big some of those VNs are, right? 5GB is considered small nowadays. :) That's a TON of animations done using transparent images and ATL.

Think about it. (And thanks, you've forced me to add one more step into workflow, but ensured me that my original approach was not that bad after all.;))
 
Last edited:

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,587
4,715
Anything animated made from separate frames will have dramatically larger storage requirements simply because the opportunity to exploit cross-frame similarity is lost. Untold millions of dollarydoos have been spent creating and optimizing video codecs to make vids have massively smaller output size while maintaining almost indiscernible quality loss.

In your example file, there's 10sec of 60fps video in a file that's only 2.2mb. Compared to the example you gave of webp encoded separate images animation which still took 18.8mb, that's a huge improvement in quality and file size.

So if possible and your workflow allows it, it seems to make a lot of sense to pursue the usage of video codec compressed animations.

Now, practically, rather than using greenscreen I'm pretty sure I've read a forum post either here or on Lemmasoft forums that explains how to use two mp4s to get transparent-cutout video over a static background - the second mp4 acts as am alpha mask so is only two color and will be much much smaller than the main video.

With some legwork, it appears you could have your animated cake and eat it too.
 
  • Like
Reactions: Sukurumanu

Sukurumanu

New Member
Feb 13, 2024
4
0
Hey, that's not bad at all!!
Actually, not even forums are necessary.
Documentation is rather clear here:

So from HS/Koikatsu you export transparent animation - in my case 600 images - 10 seconds at 60fps.
Run it thru ffmpeg twice:
1. Get mask video:
Bash:
 ffmpeg -framerate 60 -i %03d.png -vf alphaextract -c:v libvpx-vp9 -pix_fmt yuv420p idle_mask.webm
2. Get main video:
Code:
ffmpeg -framerate 60 -i %03d.png -c:v libvpx-vp9 -pix_fmt yuv420p idle_main.webm
Then in game you just use:

Code:
image crystal_idle_animation = Movie(play="images/animations/crystal/idle_main.webm", mask="images/animations/crystal/idle_mask.webm")
and called the usual way:
Code:
scene bg crystal door morning open

show crystal_idle_animation
Total size of mask and main is 3,8MB - not bad. Also, I was afraid of the possible complexity in workflow, but this is easy and renpy code is actually just one liner...

As for application in original question - you would still need to generate bunch of movies, BUT it is possible to run multiple movies over each other - just show them at the same place - so in theory you can just render parts that are different between characters - you know different color of dress, different color of skin, cum on face, with or without anal plug... ;)