Ren'Py Blinking character effect

ddeadbeat

Bewbie
Game Developer
Mar 30, 2018
143
1,636
Sorry to create a thread for such a small question, but it seems that there's no general Ren'Py questions thread.
I tried to google and search such question on this forum but didn't succeed.
My question is: how to create an effect, when while the player doesn't click, Ren'Py shows him this kind of loop:

Image with character with opened eyes "grl_eyes_opened" for a few seconds, then rapidly shows images like "grl_eyes_halfclosed" - "grl_eyes_closed" - "grl_eyes_halfclosed"
maybe with some effects, idk how would it look.

At least it's my guess how this effect should be achieved. I might me totally wrong. If so, please enlighten me!
I'm an absolute newbie both in Daz (btw, images I refer to, are renders in daz), Ren'Py and programming as well, please excuse my ignorance.

An example of what I would like to achieve, is VN Being A DIK. There are several such scenes with blinking characters.
I even used UnRen to decompile the code and unpacke images of the game (and felt like a criminal lol) to see that there are indeed 3 images of blinking. But in scripts file I couldn't find any line that addresses to those images, which was super confusing to me.
 

ddeadbeat

Bewbie
Game Developer
Mar 30, 2018
143
1,636
Thanks for the answer, I saw this article, but it looks like the code was made for that kind of VN, where there is a background and characters as "image", but in my case I have only "scenes", since I use renders from Daz. Could you help me to adjust this code to use it with scenes?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,364
15,281
Thanks for the answer, I saw this article, but it looks like the code was made for that kind of VN, where there is a background and characters as "image", but in my case I have only "scenes", since I use renders from Daz. Could you help me to adjust this code to use it with scenes?
Code:
 image girl eyes normal:
    "full scene eye_open.png"
    choice:
        4.5
    choice:
        3.5
    choice:
        1.5
    "full scene eye_closed.png"
    .25
    repeat
But this will start to be really heavy, since you'll have to double each scenes...
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
The way I imagine someone would do it is to create 3 renders in Daz for each of the positions of the eyelids, then cut-and-paste two of those sets of eyes into a much smaller couple of images. In effect, just keeping the bits that have changed between images.

Then set up an ATL composite image with timers (possibly random timers) to merge each of the pictures together to create the effect you are looking for.

So I used these images as a quick and dirty test...


eyes1.jpg eyes2.jpg

The first image is a basic render. The 2nd picture is just to highlight where I cut-and-paste the eyes from.
eyes1 and eyes2
The basic area I've selected is bigger than the actual eyes, to allow to minor shadowing to change from stuff like eye lashes).



eyes3.jpg eyes4.jpg eyes5.jpg

Then I have 3 renders of the same position, with the eye lids in different positions.
eyes3, eyes4 and eyes5.
(I didn't do any renders, so just a substitute effect using MSPaint).


I then create a RenPy image based on my "eye" only images as a pseudo animation.

Python:
image eyeblink2:
    "eyes3"
    choice:
        pause 3.5
    choice:
        pause 2.5
    choice:
        pause 1.0
    "eyes4"
    pause 0.05
    "eyes5"
    pause 0.05
    repeat
As I understand it, each choice: block as an equal chance of being executed randomly. So if you were doing it "properly", you might have more options for the longer blinks than the shorter ones (3.5, 3.5, 3.0, 2.5, 2.5, 1.5, 1.0 for example).

So I start with my "eyes open". Pause for a random time, then displays eyes4 for a fraction of a second, followed by eyes5 for another fraction... before returning back to the top to show the "eyes open" (eyes3) again... wait... rinse and repeat.

Okay. So I now have an image which includes those eye blinks.

Now to merge them back into my "base" face.

Python:
image eyeblink = Composite(
    (868,720),                      # size of the overall image
    (0,0), "eyes1",
    (182,232), "eyeblink2")         # top left corner of where I want my eyes to appear.
So now I have a merged image using both my original full sized face (eyes1.jpg) and my blinking eyes (eyeblink2).

Now I just need to display it somewhere.

Python:
label start:

    scene black with fade

    "Start:.... "

    scene eyeblink

    "**** END ****"

    return
Obviously, I've gone for a very simple example. Yours could be way more subtle than mine.

You could just do 3 full renders instead and bypass the whole "composite" image thing to only add the eyes to an existing image.
 

ddeadbeat

Bewbie
Game Developer
Mar 30, 2018
143
1,636
anne O'nymous
79flavors


Are you some kind of demigods?! It works just as I wanted! I guess I didn't know that "image" statement can be complex thing rather then just an image.
I used simplier way with just whole scenes with differently opened eyelids, since I already have those renders.
Few notes:
1. When you close your eyes, your eyebrows should also move. Good to know lol.
2. For some reason, if there is no dialog text after this image declaration and loading the scene with it, the game just ends and throws you into the main menu, without even showing the animation.

This one doesn't work:

Python:
#...game stuff...#

n "Take a seat."



image nurseblink:

    "16_medcab.webp"

    choice:

        pause 3.5

    choice:

        pause 2.5

    choice:

        pause 1.0

    "16_medcab_blink1.webp"

    pause 0.05

    "16_medcab_blink2.webp"

    pause 0.05

    "16_medcab_blink1.webp"

    pause 0.05

    repeat



scene nurseblink

scene 17_medcab

#...game goes on...#
And this one does:

Python:
#...game stuff...#
n "Take a seat."

image nurseblink:
    "16_medcab.webp"
    choice:
        pause 3.5
    choice:
        pause 2.5
    choice:
        pause 1.0
    "16_medcab_blink1.webp"
    pause 0.05
    "16_medcab_blink2.webp"
    pause 0.05
    "16_medcab_blink1.webp"
    pause 0.05
    repeat

scene nurseblink
"I have to say something, or the game will close itself!"

scene 17_medcab
#...game goes on...#
 
  • Like
Reactions: Fatalmasterpiece

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
There is something in Daz called "spot rendering".

No actual clue, beyond the name.
But my impression is that you can render a very specific part of the scene without moving the camera and/or lightning.

I've heard mention of it before when people have run out of texture memory on their graphics card(s), so they render one part of the scene (perhaps a house with people stood outside) and the same scene with those people removed, but a car and a couple of neighbors in an adjacent driveway. Combined, the card would take forever - but with specific parts rendered and then combined later... it's a lot quicker.

I mention it, because maybe... rendering just the part that covers the eyes is possible - without rendering the whole scene with the eyes in either 2 or 3 positions.

The solution to the game just advancing to the end is pause. pause will wait until the user press a key (or the mouse) and something like pause 5.0 would do the same, but also continue after 5 seconds if the player doesn't do anything too. I would recommend specifying a time, since a lot of players also play with "auto-advance time" switched on and therefore pause on its own ends very quickly. Better still is a combination of pause {time} and dialogue.

To borrow your example...

Python:
    scene nurseblink
    pause 4.0

    "I have to say something, or the game will close itself!"
This allows for players who are quickly advancing through the game, but keeps the "correct" pacing for a "normal" player.

General rule of thumb for a pause followed by dialogue. Time how long you would stare at the image, then knock 2 seconds off it. That way, the game pauses to show the image - but advances before the player might start to become impatient.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,364
15,281
There is something in Daz called "spot rendering".

No actual clue, beyond the name.
But my impression is that you can render a very specific part of the scene without moving the camera and/or lightning.
It is. It render part of the actual scene as seen through the actual camera. It's a little tricky, but not too difficult to use :

  • Use the tool settings to configure the spot render tool to render in a "new window" ;
  • Select the spot render tool ;
  • Click left and draw a rectangle around the part you want to render ;
  • A window will open, from which you'll be able to save the result.

If you select an image format that handle alpha channel and/or transparent background, whatever is outside of the selected rectangle will be transparent. Therefore, you can simply put it on top of an image to alter it temporarily.

Opening the tool settings : Window->Panes (Tabs)->Tool Settings
Selecting the spot render tool (choose one) :
  • Tools -> spot render.
  • The camera with a mouse cursor on the tool bar.
  • ALT+SHIFT+C.


I mention it, because maybe... rendering just the part that covers the eyes is possible - without rendering the whole scene with the eyes in either 2 or 3 positions.
Possible and recommended. It will significantly reduce the time needed to render the image, as well as the size of this image (and so also the size of the game).
 

ddeadbeat

Bewbie
Game Developer
Mar 30, 2018
143
1,636
It is. It render part of the actual scene as seen through the actual camera. It's a little tricky, but not too difficult to use :
Thanks! I knew about this feature, but haven't tried it yet. Guess I will, since I still have to re-do brows at least.
Though I'm not sure if this piece of image will be absolutely same in terms of tone-shadows-reflections, since all other stuff that may impact the view of rendered part will not be considered.
 

thecardinal

Latina midget, sub to my Onlyfans - cash for gash
Game Developer
Jul 28, 2017
1,491
4,426
You can place a box over part of the scene, in this case the eyes, and it will re-render what is in the box only. For example, if you run a tender to x iterations, the rest of the image will stay static at x while what is inside the box renders from the beginning but very quickly since it is rendering such a small area.

it works really well for sprites and for full scenes where one character has to be re-posed and another does not.

Has a small learning curve, but if making a game it will shave a lot of time off your rendering workload.
 
  • Like
Reactions: ddeadbeat