Hey everybody,
I’m getting some annoying flickering using ambient light in my deferred shader. The flicker doesn’t happen normally but whenever i move the camera in scene view or inspect a gameobject with the material it flickers back and forth to no ambient lighting and with then ambient.
I think it may be because i have to use ambient within the actual internal deferred shading and not the initial buffer writing shader. I’m going for a cel shaded look, so when I go through the light passes I get the maximum of the color that’s already there and the color I want to write using BlendOp Max.
Cause of that i need to add ambient light to the light color like so:
float3 steppedLight = (steppedLightAtten*light.color) + unity_AmbientSky; // UNITY_LIGHTMODEL_AMBIENT;
Because otherwise any lights that are lower than the ambient light would be ignored.
Now there are two ways I can think of to solve this.
-
I use my own color(s) in the properties of the deferred shader as a lookup texture. This way I’ll be able to edit it from script. Down side is it adds a little bit more complexity, and slows it down just a bit.
-
I make a shader that goes after the final deferred light pass. This way I can use the stock ambient values without needing to add my own. I’d also be able to apply some small after effects very easily. Down side is I don’t even know if this way would work.
My problem is I don’t even know where to start to work on these solutions.
Any help to point me in the right direction, or suggesting a different approach would be appreciated!