Point Light causing flickering on Static object
I have an issue i'm trying to resolve regarding a specific "Forward" Shader on an object i'm using and a point light that is next to it, when i move around in Game mode the lighting on the object flickers as seen here
https://gyazo.com/7ec69ec0ce02399e9eafa1a198382ea6
In the image, the gas station object and sub objects are marked as static as they never ever move, however, when I add a point light to it, baked, realtime, doesn't matter, the light flickers on the textures as i move around. I've tried modifying EVERY setting I can think of and some other advice i've looked at for similar issues (changing pixel count up to 10, etc). IF i change the shader on the object, it works fine, but i lose the shader effect i'm going for. (the shader in question is MK4/Forward/MK4_Building_Toon - these are shaders that came with the asset package i'm using. If i change the shader to the standard MK4_Building_Toon the light works properly and i dont receive any flickering, however i lose the effect of the standard shader (the toon type outline). Also if i change the object to not be static with the original shader the problem ceases as well.
Is there anything i'm doing wrong regarding lighting? Is this a shader issue perhaps? I'm very new to unity and optimizing lighting in general, and i'm not sure what i'm doing wrong here.
Answer by GamesByCono · Feb 12, 2017 at 03:51 AM
EDITED:
So the only way to solve this, to use my "Forward" based shaders and forward rendering is to turn off Static Batching in the Player Settings. This then allowed the static objects to not flicker anymore with a single point light, or multiple. I'm not sure if this is a bug or what but as of unity 5.5 (and 5.6beta) this is the only solution that worked that didn't have me completely changing the shader to a different one or turning the objects off static.
Answer by FortisVenaliter · Feb 10, 2017 at 10:48 PM
In forward rendering, the number of lights that can affect a single object is heavily limited. So, if you have more than a few lights, unity will try to choose the best ones to apply at any given time. When you move around and it appears to flicker, you are seeing that decision change.
There are a few ways to correct this. Deferred shading can handle many more lights. Breaking down your meshes into separate components allows Unity to choose lights for each component, which tends to make it more consistent. Or, if the light is really important, you can set it as important in the light settings, but if you do so for all lights, you'll have the same problem.
Look into the information on the different rendering paths of Unity for more information on why it behaves this way.
Thank you for the response!
Unfortunately none of this solves the issue. I only have this SINGLE point light in my scene, I have a directional light as well of course. I guess i'm not understanding why when i change the shader it works, or when i set the object as not static it works.
I've tried going into Project Settings -> Graphics and unchecking the Use Defaults on each of the Tiers (1,2,3) and setting their rendering path to Deffered and this still occurs. I've tried setting the light to Important.
The only way to solve the issue is to change the shader or to change the object to non static with the forward based shader.
I'm still at a loss here, nothing i do beside the two mentioned methods fixes the issue with the blinking light issue in the gif. Is this just simply a shader problem? And if so, what could/would be the cause of it. It's hard to understand all the intricacies of the lighting system and limitations when i'm unable to resolve a simple lighting issue :( I've banged my head on this for 2 whole days lol Hoping to find an AHAH moment soon though!
This still happens on recent versions of Unity by the way. And sometimes is just not possible to switch to deferred compatible shader (like when doing transparent lit stuff or screen grab pass effects). $$anonymous$$y take is that a batched object loses the individual pivots of the pre-batched ones and has to use a single one for deter$$anonymous$$ing which light to use. Did you ever find a solution?
Answer by cmx · Dec 13, 2017 at 12:05 PM
Hi, I'm having the exact same issue in 5.6.1p1. Anyone have a solution for it? It seems to happen if you use custom lighting in your shader, with batching on. thanks, Mike
Your answer
Follow this Question
Related Questions
Why is this point light square? 1 Answer
How do I reset a static gameObject? 1 Answer
Point/Spot lights only emit half of the light on my terrain 6 Answers
In-game 3D objects appear lit, although they have dark material on them 0 Answers
How to get the bone transform matrix in the vertex shader? 0 Answers