A material (shader) blinks (flickers) at a certain angle.

Hi!

Please tell me why, at a certain angle, a plane with a certain material (shader) blinks (flickers)? I read different forums, changed a lot of camera settings, light settings, material settings, and Unity Project Settings, turned off all the effects (smoke, snow). Nothing helps.

I don’t know what to do? Please tell me how I can get rid of this render defect?

Thank you!



Contact the author of that asset, NatureManufacture.

The asset store page also mentions a discord you might try.
https://assetstore.unity.com/packages/vfx/shaders/ice-world-83543

1 Like

Thank you for your advice, but as far as I understand, this is not the problem of the asset author, but of Unity itself. But I will write to the author.

One month ago I wrote to the author. The problem turned out to be in the ice shader. This shader cannot work with more than one light on the scene. That is, 2, 3, N lights create such an error in the shader - it starts to flicker. :frowning: The author tried to fix this error, but still can’t do it. Hopefully, over time, he will solve this problem. If he solves it, I will report here. :slight_smile: In the project I just use one light source, now. It is a pity that it is not possible to use several light sources - the ice turns out to be more beautiful.

I found that the problem is more serious than I thought. Any light on the scene in any object lying on the ice flickers. :frowning: Watch the reflected light from objects on the ice in the video… It is very annoying? I wrote to the author of the asset. I hope he will fix the error. But, to tell the truth, for 2 months now, for some reason, he can’t do this.

That strikes me as a different “bug”.

Unity’s has a setting for the max number of per pixel lights per forward rendered object, which the ice is going to be. If your ice sheet is a single giant mesh, only that many lights can affect it at one time and Unity will disable any beyond that limit based on some very basic heuristic for which ones are more “important” (likely not much more advanced than what order they appear in some internal list of all lights).

Check your project’s Graphics settings. Right at the top under the “Rendering” section there should be an option called “Pixel Light Count”. It’s probably set to something like 3 or 4. You can set that to a higher number to get around this, but the “real” fix might be to cut up your ice sheet into smaller separate game objects / quads so each can be lit individually.

This isn’t really a bug, but rather a common limitation of any forward renderer. Especially very old ones like Unity’s. Note, even if you’re using deferred lighting for your project, the ice is a custom shader not using the Standard lighting, and thus has to be rendered using forward rendering, just as any transparent material will as well.

2 Likes

Very interesting! Thank you so much for the information! I’ll pass it on to the author. We are currently discussing this problem with him and trying to solve it. By the way, we have already changed Pixel Light Count in different ways: 4, 5, 10, 20, 33, 100 - nothing changes.

https://www.youtube.com/watch?v=JV9XBtwACl4

But the most interesting thing is that this does not happen with the standard Unity shader with transparency Unlit/Transparent. So, logically, there is an error somewhere in the shader code itself, I think.

https://www.youtube.com/watch?v=yk60jMMQxXY

Ice use standard lighting. From our test pixel light count should fix it.
https://gyazo.com/ca01127cfd6e549ce7d9738986bed94f

1 Like

In my case, this method does not work.

There is only one global Directional Light on the scene that illuminates the ice.

https://www.youtube.com/watch?v=c_mobhQ2qyc

And it does not depend on the effects of particles.
If I turn off the blizzard and/or snow, everything will be the same.

https://www.youtube.com/watch?v=JV9XBtwACl4

That glow you’re seeing popping in and out, those are from additional lights. I suspect every single item on the ground has an effect on it that is using a light… possibly several lights per object.

This frame in particular is especially telling:
7345862--893579--upload_2021-7-20_11-2-5.png
This has most of the lights “disappearing”, but some are still visible, which makes me think you have some effects using per particle lights with a lot of particles, which can easily explode the number of lights in your scene and cause the issue you’re seeing.

I’ve noticed per particle lights are a very popular thing to add to vfx assets as they can make them look a lot better, especially when shown one effect at a time. But in real use you should almost never ever use per particle lights for this exact reason.

1 Like

I’d also suggest bringing out the frame debugger and trying to pause the game when the problem shows up. Then step through the rendering and see how many times the ice is being rendered. I’m going to predict that when you have your pixel light count set to 30, and you see some things flicker off, the ice is still getting rendered 30 times.

1 Like

There are no particle lights as far as I know. Blinking occurs even without objects on the ice. Look in the beginning of this issue - there the ice blinks simply because it is illuminated by more than one light (Directional Lights).

https://www.youtube.com/watch?v=sZGch1dPXhA

Objects on the ice have add lights when they appear on the scene. And the blinking appears again. Blinking occurs if more than one light source appears on the scene and the rays of additional lights fall into the camera.

It seems that the ice shader cannot process more than one light. IMHO. :roll_eyes:

I pulled everything into a separate scene and tested in it. I must agree with bgolus
and NatureManufacture, they are right. It’s all about the Pixel Light Count parameter. There’s nothing wrong with ice shader!

I had 4 farm objects on the scene and each had 2 lights - everything started working correctly as soon as I set Pixel Light Count = min 8 (or more). As far as I understood, I need to increase the Pixel Light Count in the original scene, for example, to 1000 and see the result (because there can be a lot of lights in it). And if this does not help, I will look for where the particles with lights appear and correct them to simple ones.

The question is closed! Thanks for your help! :slight_smile:

1 Like

Hi again!

I tried to solve this problem and count the number of light sources on the scene in runtime.

var foundCanvasObjects = FindObjectsOfType<Light>();
         
pixelLightCount.text = "PixelLightCount: " + QualitySettings.pixelLightCount;

lights.text = "Lights: " + foundCanvasObjects.Length;

But both in the assembly and in the editor, there is still a flicker. I don’t understand what it depends on. Maybe I find all the active light sources by the wrong way? I set the value of PixelLightCount = 1000 - it didn’t help. I turned on and off snow and blizzard - the result is the same. On the scene, I have no light sources in the particles - I removed each object after object.

Maybe it depends on the type of light source or the overlay of layers of effects, or on the number of frames per second (fps)?

Please help me figure out how to get rid of this flicker!

Thanks!

https://www.youtube.com/watch?v=2VaiC9sqrNk

https://www.youtube.com/watch?v=1Mp3MmW8zQI

I have already left one light source on the stage and increased PixelLightCount = 1000, checked all objects and particle systems by the method of exceptions and shutdowns - the result is the same.

Most likely, I assume that the flickering of light at a certain angle comes from the customizable effects of snow and blizzard and fog (in Window–>Rendering–>Environment–>Other Settings–>Fog–>Density).

In short, apparently by the communication with the author of the asset and for many other reasons, I’m starting to think that this is a problem of the Unity Engine itself.

If someone can dissuade me in it and somehow help solve this problem - I will be very grateful!

Recently I had a similar problem on MacBook (with Radeon GPU). It was caused by enabled Screen Space Reflections from Post Processing Stack v2. Problem was fixed by updating Post Processing Stack into the newest version (3.0.3.).

1 Like

Interesting information. Thanks! Do you know what version of the Post Processing Stack is in Unity 2020.2.3.f1? As far as I understood v2 (https://docs.unity3d.com/2018.2/Documentation/Manual/PostProcessing-Stack.html). Can it be upgraded to v3? Or is it necessary to switch to the Unity 2021 version?

I recently discovered that this problem is also present in other scenes. :hushed: I will provide the video below.

Post Processing Stack is installed manually from Window - > Package Manager (Advanced - > Show Preview Packages). Maybe your project has assets from Assetstore which automatically installed PPS and use it.

1 Like