and i would like to insert models that would iluminate the surrounding area/and objects giving them color.
All models have already colored textures and the gray/green screen color is achived by diffrent full screen image effect shaders.(mostly by grayscale color correction)
Now i would like to give some objects some color to achive an effect that an object by its ilumination gives color for desaturated environment.
1 Idea for solution no1. remove all grayscale image effect and color corection from camera.
disaturate world by givin each material starting saturation S=0
and then calculate its saturation by the distance from the color givin object.
The first problem with this idea is that the objects would be saturated equaly on each side and that would break the ilussion.
“Some crazy object shader never heard of” mixed with idea no1
3 “some image effect shader?”(i find it rather impossible since these are rather post proceses effects)
mayby there are some other solutions for this kind of problem?
best regards
create a custom full screen pass to render an accumulated mask into
create a custom “light” object, think of it like a deferred point light, eg:
Spherical bounding mesh to reduce fill rate
when outside the sphere, test Z less or equal
when inside the sphere, test Z greater or equal
do a simple attenuation + optional NDotL term
After drawing all your custom mask lights into this buffer, do a custom desaturation image effect which uses the above mask to apply the desaturation or not.
pro’s:
totally custom falloff, and other optional visual elements
make a custom mask object which writes to the stencil buffer. Flip the Z test like option 1 so it works from inside and outside the volume.
do a grayscale image effect which reads from the stencil mask to exclude areas (leaving them saturated)
pro’s:
only a few bits to get it working
cheap!
con’s:
binary on/off effect
could be extended to do the NDotL term, but will still be binary on/off
And for crazy town idea (which works, is cheap, and easy, but has limitations…): option 3:
create a controller which builds up a list of n visible (on screen) saturation probes. This would contain position, scale, and intensity
sort the list into a pre-defined number of supported probes (eg, pick the closest 16), and pack this info into vector4’s to be uploaded to…
a custom desaturation image effect which loops over the list of 16 probes, summing up their effect in the world and then uses that to desaturate the image.
pro’s:
very low complexity
still fairly cheap (depending on how many visible probes you allow)
all the visual advantages of option 1
con’s:
limit to the amount visible on screen (this could be partitioned into quadrants, or faded out over distance, etc, so there’s lots of options to toy with it though)
The thing is also that i would like to applay this effect dynamictly. objects moving around the scene givin saturation for near environment.if you were to chose an option to start with, which would have the highest chanse to work? Am asking cause’ ill have to swallow quite a bit of shader creation knowlage and trying all the options at once could be a bit overwhelming. Thank you for your vast response . you must be some kind of shader wizard or something
I did something similar to this a couple of years ago as a proof of concept for a 2D game. I don’t remember all the details, but I basically had a two camera setup. One camera showed the world as greyscale, while the other used particles as an overlay of the color version.
i just tried it .its a good solution for 2D game as you used it that way:) I tried it like 5 min ago. it works to some extend in 3d up to the moment when you put some geometry before your colored model… hehe I guess its called overley for a reason:)
The solution Jacob offers would definitely work as another method for the application of the mask.
Tangent: I like it - it’s very similar in principle to setting up a second dependent image pass, but you’re just blatting a mask straight in with whatever is in your layer cull mask of your camera. I can see two different ways to do this too, either reading the first scene camera’s color source (pre-desaturating) on the particles directly, or doing it in a grayscale pass reading in the camera source with the particle mask as your saturation/desaturation mask.
So it’s all apples and oranges at this point - it’s all just ingredients to make up the effect you’re after. Applying the mask is fairly trivial… you’ve now got a number of options to do that.
The hairy bit is generating the actual mask weight to work from. Eg, If you want it to work like a “light” (3D intersection of the environment, like a light attenuation term, optional directional shading… let’s not even consider shadowing for the time being).
My recommendation is look into deferred point lights and the common way they’re created – that’s the part of option 1&2 I gave regarding the sphere and ztest flipping when you’re outside vs inside.
After that you’ll need to use the depth buffer in its shader to generate a world space position of the world (not the sphere), and generate an attenuation term. If you want shading, read in the scenes normals and do a simple NdotL.
Iam getting down to work. if i have any progres with i’ll post the resoults.i hope this line of posts will also help others who seeks to create such effect.greate respect for all the ideas and for the links:) They are going to be more then usefull