How to blur background during conversations and choices?

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
Vennnot
Newbie
Posts: 12
Joined: Mon Mar 19, 2018 4:48 pm
Contact:

How to blur background during conversations and choices?

#1 Post by Vennnot »

Hey everyone!

Is there a way to blur backgrounds and menus during conversations?

I'm happy using 2 versions of the same background (blurred and unblurred) if it makes it any easier?

If it's the same then I would rather have it in the engine.

Thanks for all the help!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How to blur background during conversations and choices?

#2 Post by Per K Grok »

Vennnot wrote: Wed Mar 10, 2021 3:09 pm Hey everyone!

Is there a way to blur backgrounds and menus during conversations?

I'm happy using 2 versions of the same background (blurred and unblurred) if it makes it any easier?

If it's the same then I would rather have it in the engine.

Thanks for all the help!

There is probably a more elegant way of doing this with image manipulation, but here you have a possible and very hands-on method.

You start by creating an image just using code with one color, in this case white.

image white="#fff"


When you want to blur the background you place the image white over it and set the alpha value (transparency). If you do it like this you get a soft transit to the blurring

Code: Select all

    show white:
        alpha 0.0
        linear 0.2 alpha 0.5
When the blurring should stop simply hide the image white, possibly with a reverse change of the degree of alpha.


If you just want to have the one degree of alpha you can set that as a forth value when you define the image.

You could use black or any other color to get a different model of blurring.

An important thing here is to make sure you get the image on top of what you want blurred (which might be more than just one image) but behind anything you don't want to be blurred. You might need to use zorder for this, depending on the circumstances.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: How to blur background during conversations and choices?

#3 Post by _ticlock_ »

There is an ATL property blur. You can use it to blur an image when you want it:

Code: Select all

define config.gl2 = True          # Blur requires model-based rendering to be enabled by setting config.gl2 to True.

label start:
    scene scene_01
    "Scene - No blur"
    scene scene_01:
        linear 1.0 blur 10.0
    "Scene - With blur"

Vennnot
Newbie
Posts: 12
Joined: Mon Mar 19, 2018 4:48 pm
Contact:

Re: How to blur background during conversations and choices?

#4 Post by Vennnot »

Hmmm ok. And how do I make it happen during conversations and choice menus?

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: How to blur background during conversations and choices?

#5 Post by zmook »

Vennnot wrote: Thu Mar 11, 2021 3:19 am Hmmm ok. And how do I make it happen during conversations and choice menus?
Pretty much like _ticlock_ showed. Show your scenes with blur when the characters are talking or you have offered a menu, and unblur on the (presumably rare?) occasions when they stop.

Code: Select all

define config.gl2 = True          # Blur requires model-based rendering to be enabled by setting config.gl2 to True.

transform blurred:
	blur 6
	
transform enblur:
	blur 0
	linear 1 blur 6

transform deblur:
	blur 6
	linear 1 blur 0

label start:
    scene scene_01                        # not blurred
    pause                                      # let the player look at it
    scene scene_01 at enblur         # animate in some blur 
    a "Hey, want to talk?"               # conversation over blurred background
    b "Yeah, let's talk."
    scene scene_02 at blurred         # display scene already blurred, no animation
    a "It's really fun talking to you."
    scene scene_03 at blurred
    b "Let's talk over here."
    a "You know what I'm bored now."
    b "Yeah, let's stop talking and look at the scenery."
    scene scene_03 at deblur           # animate away the blur
    pause                                      # let the player look at it
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: How to blur background during conversations and choices?

#6 Post by m_from_space »

You can create blurred versions of every image like this and use it with the standard show command:

Code: Select all

image eileen blurred = im.Blur("path/to/eileen.jpg", 1.5)
For example, if you want to have a dynamic way to blur the background in every choice interaction in a scene you would need to keep track of what image is shown at the moment. So here is an idea:

Code: Select all

image bg1 blurred = im.Blur("path/to/bg1.jpg", 1.5)
image bg2 blurred = im.Blur("path/to/bg2.jpg", 1.5)
default current_scene_background = "None"

label start:
    scene bg1
    $ current_scene_background = "bg1 blurred"
    menu:
        "Option 1":
            pass
        "Option 2":
            pass
For this then to actually work you would alter the "choice" screen in screens.rpy for example:

Code: Select all

screen choice(items):
    style_prefix "choice"

    if current_scene_background != "None":
        add current_scene_background

    vbox:
        for i in items:
            textbutton i.caption action i.action
There are definitely ways to make this more efficient, it's just a hint. ;)

Post Reply

Who is online

Users browsing this forum: No registered users