Applying a tint to a whole scene in the game

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
harajukulolita
Regular
Posts: 75
Joined: Mon Jul 15, 2013 11:24 am
Completed: None so far!
Projects: Currently working on... Starlight Wishes
Tumblr: loli-studio
Deviantart: harajukulolita
Contact:

Applying a tint to a whole scene in the game

#1 Post by harajukulolita » Wed Aug 13, 2014 6:16 am

Hi everyone, I'm sorry if this question has been asked before and I haven't seen it. I wanted to know how to creat a tint for a whole scene in the game. For example, if it were a memory then the whole thing would play out in a sepia or greyscale tint.

I know that this can be done with individual images using the im.Sepia and im.Greyscale operations among others but can how do I apply the sepia or greyscale to the whole scene without defining individual images?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Applying a tint to a whole scene in the game

#2 Post by xela » Wed Aug 13, 2014 8:46 am

You can't, scene isn't an image.

I have no idea on how this can be done, maybe a solid with a tweaked alpha channel. That could potentially give the scene a darker look but it's far away from greyscale effect.
Like what we're doing? Support us at:
Image

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Applying a tint to a whole scene in the game

#3 Post by Asceai » Wed Aug 13, 2014 8:47 am

Ren'Py currently can't do this in any half-decent way. The only matrix colour operations available are image manipulators. They can't be applied 'live' so you can't e.g. make a Transform that turns everything grey.

Now, to get around the 'defining individual images' part, here's a hack I wrote. It is the very definition of a hack because it uses undocumented internal Ren'Py functionality (specifically, the 'images' dictionary, used to get a list of images) but it creates greyscale versions of every image.

Code: Select all

init 999 python:
  grey_images = {}
  for i in renpy.display.image.images:
    try:
      grey_im_name = i + ('greyscale',)
      grey_images[grey_im_name] = im.Grayscale(renpy.display.image.images[i])
    except:
      pass
  for i in grey_images:
    renpy.image(i, grey_images[i])
So, instead of 'show picture' you can use 'show picture greyscale', instead of 'scene background' you can use 'scene background greyscale' etc.
It'll only work with images that are image manipulators - if you have something like an animated image, this won't work with that - while greyscale versions of the individual frames should exist, the code won't know how to use them.

I don't currently know a good way of delivering the second requirement - making everything greyscale automatically. The simplest way is to redefine config.show to check a flag (e.g. greyscale) and apply the 'greyscale' attribute to shown images if it is set (I use getattr to check it so it won't bug out if you haven't set greyscale yet):

Code: Select all

init python:
  def replacement_show(name, *args, **kwargs):
    if getattr(renpy.store, 'greyscale', False):
      renpy.show(name + ('greyscale',), *args, **kwargs)
    else:
      renpy.show(name, *args, **kwargs)
  config.show = replacement_show
This way you can just set the flag and all subsequent shows will use the greyscale variants:

Code: Select all

label start:
  scene forest_bg
  show girl
  girl "Hi!"
  $greyscale = True
  scene forest_bg
  show girl
  "I remembered this place from my childhood..."
  return
There's numerous downsides to this. First, it won't work with renpy.show(), only 'scene' and 'show' statements. It won't work with anything that isn't specified as an image manipulator, so animations etc. won't work (you'd want to create new versions of them with the greyscale image attribute if you use them in these scenes). You also have to re-show everything in the scene to get them to appear in greyscale - the screen doesn't just go grey automatically.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Applying a tint to a whole scene in the game

#4 Post by xela » Wed Aug 13, 2014 10:22 am

For any game that doesn't use "live" displayable atm when stuff needs to be greyscaled, this is an excellent workaround. You could potentially define a number of tints and have it go to back/white gradually... excellent example!
Like what we're doing? Support us at:
Image

User avatar
harajukulolita
Regular
Posts: 75
Joined: Mon Jul 15, 2013 11:24 am
Completed: None so far!
Projects: Currently working on... Starlight Wishes
Tumblr: loli-studio
Deviantart: harajukulolita
Contact:

Re: Applying a tint to a whole scene in the game

#5 Post by harajukulolita » Wed Aug 13, 2014 12:20 pm

Thank you for the advice, not that I mind spending the time defining each image I'm going to use in the scene but it would just be so much better if there were shorter and practical ways of doing this. I'll give this code a try and see how things work out thank you very much :D

User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Re: Applying a tint to a whole scene in the game

#6 Post by SONTSE » Thu Sep 21, 2017 10:23 am

I run into same problem recently, and found this thread.
Asceai solution does work, but it seems modern RenPy auto-define images from "images" folder bypassing the routine that was hacked by the script above, so they are not affected.
Could you please fix the script to include those auto-defined images?

Or is there more decent way to handle that problem so far?
Thanks!
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

CellHG
Regular
Posts: 61
Joined: Fri May 05, 2017 3:01 pm
Contact:

Re: Applying a tint to a whole scene in the game

#7 Post by CellHG » Thu Sep 21, 2017 3:24 pm

Can you not create an overlay/screen with the desire effect as an image?

Then do the show screen to show said overlay?

User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Re: Applying a tint to a whole scene in the game

#8 Post by SONTSE » Thu Sep 21, 2017 4:11 pm

CellHG wrote:
Thu Sep 21, 2017 3:24 pm
Can you not create an overlay/screen with the desire effect as an image?

Then do the show screen to show said overlay?
An effect that operates not a single image (like usual effects do), but composite displayables (e.g. whole layer or screen), or simply applies into everything behind it would be exact thing I love to be pointed at. ^^
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Grempy