- Home /
Image effect shader that masks spritelayer
I want a image effect that colors the background layer black and all other layers white like this :
How would I go about doing this. Will I need multiple cameras? How would I go about doing this, I'm very much not a shader expert? Are there shaders like this on the internet already made?
I personally would use replacement shaders.
Edit Was reading an article on command buffers at the time, has nothing to do with this post. Whoops.
Answer by tanoshimi · Oct 21, 2016 at 07:18 AM
An image effect is a post-processing effect that deals with pixels after they have been rendered to the graphics buffer. As such, it knows nothing about "sorting layers", since those are used to control only the order in which they are rendered.
There are a couple of alternatives:
You could modify the shaders used by your foreground sprites to write to the stencil buffer, and then use that as a basis for the mask.
You could use replacement shaders.
Or, probably the easiest (and the only one that's directly sorting layer-based) is to render your background and foreground sprites to two different cameras, based on their culling masks. When you want to show the effect, turn off the background camera, and apply some simple whiteout image effect to the foreground camera (probably turning the brightness up an insane amount would get the effect you want)