I am trying to make a game where particular "light sources" bring color to an otherwise grey world. I am extremely new to the world of custom graphics processing. I assume it will require a custom shader of some description but don't know how to go about adding variables to shaders which can be read at runtime.

Pretty much pull the saturation out of everything unless its hit by something which behaves much like light does (objects block it from hitting things behind it; there is a gradient of distance vs intensity; some sort of single bounce would be nice but understand that is computationally expensive.) Honestly would be fine with it being a standard light source which gets detected. If that surface/pixel hit by that light source, don't mess with the saturation.

You can get pretty close to what I want with post-processing and a luminosity-saturation curve but then it gets affected by other light sources.

Using the URP at the moment, but if that has to change, then so be it. The entire games' feel revolves around this.

Many thanks in advance if anyone can point me in the right direction, or even in the direction of some good tutorial material. Unity's docs with regard to graphics are all over the place and not particularly helpful to those who are new.


1 Answer 1


I'd handle this in passes.

Your first pass renders your scene with shader replacement, rendering everything in plain diffuse white with no normal maps/etc, and no ambient term. Place your saturation-casting lights and your conventional lights on their own separate layers, and configure your camera for this pass to use only the saturation-casters. Output the result to a RenderTexture. You'll end up with a greyscale map in this texture, where bright areas should become high-saturation and dark areas low-saturation.

Your next pass renders your scene as usual - the camera for this pass should ignore the layer containing the saturation-casting lights.

Lastly, apply a post-process to the output of this pass, to tweak its saturation before outputting to the screen, using the greyscale texture saved in the first pass as a saturation multiplier.

  • \$\begingroup\$ Is this all from a single multi-pass shader (+ the white diffuse) or a combination of sharers, render assets and a few cameras to layer things? \$\endgroup\$
    – Angus
    Commented Aug 19, 2022 at 2:32
  • \$\begingroup\$ Note that I discuss using multiple cameras, a RenderTexture asset, and a post-process shader, and that question should answer itself. \$\endgroup\$
    – DMGregory
    Commented Aug 19, 2022 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .