[Bug Reported] - Baked Shadow Angle Doesn't Work Correctly In Stationary Mode

Hi,

I have already posted this as a bug report (Case 878049), but thought I would post it here as well (as the Being A Good Beta Tester docs tell me too!)

I have noticed that the Baked Shadow Angle property has a dramatically different effect in Stationary Vs Static light modes. I’m assuming that the static shadow is how it is supposed to look, and that looks great, it’s the exact kind of look I need for my game. The problem is that I can’t achieve the same look in Stationary Mode (ShadowMask mode, but probably others)

Static Light With Beautiful Shadow:

Stationary Light With Shadow…

The whole point of me baking in my shadows and lighting is not only to save computation time at runtime, but to produce better than realtime lighting. Right now, I’m not so sure the Stationary mode is offering this, with regards to shadows at least.

Any help is appreciated in terms of settings to improve the Stationary mode, but I’m guessing this is something that will need to be looked at in the engine code.

Some Notes:

I have tried to keep the setups as similar as possible, the only real difference (apart from the lighting mode) is the intensity I set on the light (0.5 vs 1) in order to try and match the overall scene colours.

I am using quite a bright ambient light color and the Stationary scene appears very washed out with an intensity of 1.

As an aside, I’d be interested to know if the very different looks with the same light settings, but different modes is expected. If not, I can submit another bug.

Cheers,

Niall

Hey @nindim

First of all, thanks for reporting this issue. Your bug report is already processed and came to our attention. I’m currently investigating this and realized that there are a couple of problems.

  1. Using auto mode creates inconsistent results (however clearing GI cache and perhaps a reboot may help). So as a workaround, please use the generate lighting button to manually build the lighting in the scene. If you do so, you will see that it generates the same output.

  2. Now, this question shows that we still fail to communicate successfully in terms of explaining what each light mode does. But we’ll create more visual materials to describe what type of differences you should expect.

So long story short, yes - it is expected. Let’s take a look at your example:

You have static objects in your scene and you toggle the type of your light source between static and stationary mode when the light mode is set to shadowmask. When it is set to static, everything is baked. Both direct and indirect lighting are stored in lightmaps and there is no specularity. When you set the directional light to stationary though, this behaviour changes. In this case, stationary light contributes realtime direct light (unlike static) and lightmaps + light probes are used for indirect lighting. In addition, we have realtime specularity with stationary lights. Therefore, this creates mildly brighter results (please observe the result below that shadows are rendered the same way but only brightness is different).

If you set your light mode to subtractive, you will realize that both direct light and specularity are baked as well, therefore creates the same result as baked lighting.

If the light mode is set to Distance Shadowmask, this is another story - within shadow distance static objects cast realtime shadows, as you have probably read. Thus, different results are expected in each light mode.

Now, I went ahead and isolated your scene. When comparing, it’s always a good practise to isolate the issue in order to get accurate results. There are many things involved when you’re building the lighting (e.g. Precomputed Realtime GI, Ambient lighting and whatnot). So I’m attaching the project (check the stationary scene) and the screenshot below.

I hope that clarifies the issue.

Thanks,
QA Team

2954782–219188–Statics.rar (462 KB)

Hi,

I am not using auto mode to build any of my lighting, it’s the first thing I switch off when I create a new acene. The project I sent in with my bug report was using manual baking as well, so not sure how your first point will work around the issue?

I can see from your screenshots the shadows look similar, were you able to achieve the same with the test project I sent you?

What you have explained about the different lighting modes is roughly what I picked up from the forums and docs already, so maybe you’re doing a better job than you think? :slight_smile:

The discrepancy I’m seeing is much more than a subtle difference in brightness though. I had to set the intensity of one version of the light to 0.5 while the other was at 1 to achieve a similar result in both scenes. Perhaps there is a setting in my project causing this? Do you have access to investigate?

I will try and post some screenshots of the discrepancy when I have access to a computer and perhaps create a new thread for this.

Cheers,

Niall

Hi,

I have just managed to look at your attached project in 5.6 beta 7 (I was previously on beta 5).

I’m not seeing what you have in your screenshots above at all.

The Stationary scene is very very dark, I think maybe you changed the ambient colour to black by mistake?

I set the ambient the same as the static scene and rebuilt the lighting, the shadow looks rubbish and the scene is much brighter than the static scene.

The static scene, all good here! :slight_smile:

So to summarise, the shadows look completely different (MUCH better in static mode) and the scene is MUCH brighter in stationary mode.

Any ideas? :frowning:

I noticed that there are a lot of other different light settings for the stationary scene, I have re-added the skybox, set the reflection source to skybox and altered the resolution parameters as necessary. The lighting setup is now a 1:1 match with the static scene from what I can tell.

I made an animated gif to A-B the images…

free image host

I’m not going mad am I? Surely this can’t be expected behaviour?

What is interesting is that the brightness/lighting of the cube seems to be almost identical between the two scenes, it’s the floor plane that changes dramatically. The bad looking shadow is also cast onto this same floor plane… Coincidence?

Update: It’s occurred to me that in your original images, perhaps the lighting in the stationary scene was the “correct” one. Maybe if I had turned off the skybox, reflections and dialled the ambient down to pure black, the scenes would have looked the same, but that’s not really much use to me when I need to use all those features :slight_smile: I’m guessing that maybe the bug lies in one of the lighting features that was switched off for you to produce the images above.

Hi @nindim

First of all, instead of stationary (previous mixed) and static (previous baked), we reverted back to original mixed/baked terminology with Unity 5.6.0b9 (not public yet) therefore I’ll use this terminology from now on.

Secondly, as you mentioned in your last post, it was only the Stationary scene in your project that I used to make the changes. Certainly, it could be ambient light, reflections or skybox that interfere with the shadows. By isolating, I’ve tried to narrow down the issue. But what I meant is, things like brightness are expected and the results you get in mixed mode will never be the same as baked mode. Hence, you should manually adjust the intensity of your light for your needs if that’s what you are looking for. And the main reason behind this is because baked mode is meant to be used with only static objects, whereas mixed mode is also applied to dynamic objects (realtime direct light is applied on top). Basically, each mode has different functionalities. What matters in the mixed mode is to achieve consistency across dynamic and static objects. So using baked mode as a reference is not correct. (Try changing intensity when Auto mode is enabled, you can observe that realtime direct light is applied and it’s causing brighter results than baked).

So the shadows issue you refer is much more like an intensity issue as you can get a similar result if you tweak your intensity to match. And this is by design, you should manually tweak that parameter. Same thing applies to baked shadow angle parameter. And the way ambient light or reflections work can be different depending on which light mode you are using.

I hope this makes sense?

I was reading the bug report processed by another QA therefore this created a confusion. I now realized that you reported without auto enabled, so please don’t mind that.

Lastly, I couldn’t reproduce the case where you have the same bright cube regardless of baked/mixed mode. Could you perhaps try generating lighting again after clearing your GI cache and baked data if you continue to encounter that issue?

FYI - I also replied in the other thread.

Thanks,
QA Team

Update: This particular issue where the lighting dramatically changes between lighting modes looks to actually be a (legacy) shader problem, please see my post below for details. The issue with shadows and Baked Shadow Angle remains though.

Thanks for the suggestion, unfortunately I have been cleaning my cache and clearing baked data before manually generating the lighting data since the issue was first highlighted to me a week or two ago, so that doesn’t help. Maybe an option to disable the cache for now while you guys fix it?

Please find a project showing the issue where the plane is much brighter while the cubes look similar.

The scenes I am comparing ONLY feature static objects so I would expect the results to be similar.

I think it is a mistake to say that lighting should be expected to look different between modes. It would make much more sense for Unity to develop a baseline for what lighting looks like that is consistent between modes when the same light direction and intensity etc is used. This would enable the end user to change their lighting mode mid project without having to reconfigure many lights (perhaps hundreds!).

The 5.6 release seems like a perfect time to unify your lighting modes when you are already making such large sweeping changes to mixed mode (which hasn’t been working properly for a long time).

Perhaps you could provide an update route that would modify existing project light intensities automatically so they look the same after the upgrade process, this would enable the best of both worlds.

I’m hopeful that this can still be fixed. I understand that this may delay the lighting changes, but as a community we have waited a long time for a working lighting solution, I’m sure we can wait a little longer.

2960958–219819–StaticVsStationary_CubeSmiliarPlaneVeryDifferent.zip (880 KB)

In terms of the inconsistent plane lighting between the two scenes, I have found something interesting:

The plane is using the “ground” material in both the static and stationary scene. The ground material is set to use the “Legacy Shaders/Diffuse”.

Setting the ground material to the standard shader instead makes the plane appear similar in both scenes.

Setting the ground material to use “Mobile/Diffuse” produces similar results to the standard shader.

So it looks like this particular problem is limited to the Legacy shaders… Is this expected behaviour? I thought these shaders were legacy, but should still be expected to work.

In terms of my initial bug report, the shadows:

I have included a new test project for testing purposes. Notice that I have assigned a new standard shader material (DefaultMaterial_NoReflectionsNoSpecular) which is basically the default standard material values, but I have turned off specular and reflections. I have done this to try and get more consistency between the baked and mixed mode lighting setups to rule them out (as I know specular for instance is not calculated in Baked (Static) mode). The lighting now matches exactly between the scenes using the standard shader and as such rules out intensity issues (As you previously speculated).

Please see the project attached below and the embedded animated gifs (click for full resolution).

Notice I have not had to make any adjustments to the lights intensity between modes to achieve consistent results. This is good!

In conclusion, it seems like we have 2 separate problems:

  1. The baked shadow angle does not look right in Stationary Mode Lights (Shadowmask, but maybe others as well). This is the problem I first mentioned in this thread.

We have lovely soft shadows in Static (baked) mode, but almost hard edge shadows in Stationary (mixed) mode.

This is not an intensity issue as you previously speculated given that now the lighting matches 1:1 between the two scenes with the exception of the shadow.

  1. Legacy shaders (at least Leagacy/Diffuse) do not seem to work consistently between lighting modes. This is a newly discovered issue by the looks of things? Please take a look at the _LegacyMaterial versions of the Static and Statioanry Scenes in the included project. Notice how different they look between the two lighting modes.

Hopefully this new information can help put my original bug report to rest. There is definitely an issue isolated to the shadows between modes.

Thanks a lot,

Niall

2961057–219824–StaticVsStationary_BakedShadowAngleIssue_LegacyShaderIssue.zip (63.1 KB)

Any update on this?

Cheers!

Bump

Hey @nindim ,

Thank you for taking your time to report your observations here, we appreciate it.

I’m glad to hear that you sorted out the intensity issue by disabling the specularity.

So regarding your questions:

  1. We have two bugs about this.
  • Due to texture format, baked soft shadows look different. This is reported.
  • Building the lighting in manual and auto mode renders different results. (You can observe this in your Stationary test scene) and I’m attaching the comparison below (captured from the device)

Devs simply didn’t have the time to look at these issues yet due to other cases and priorities but will look at it as soon as they are available.

You may want to vote for the issues here if you think these bugs affects your project severely so that we can prioritize these cases:

  1. As you already noticed, there is a reason why some shaders are legacy. From now on, resources won’t be spend on legacy shaders anymore. Eventually they’ll be deprecated but some people still use it so that’s why it is still kept. But they are not expected to work properly with new features.

Thanks,
QA Team

1 Like

Hi @nindim ,

We realized that this issue is specific to gamma mode. In Linear, it works correctly but given that you’re developing your game for mobile, you still need the fix for gamma color space. We realized that the issue is related texture readback so it should just be a matter of reading in the texture correctly. We’ll try to provide a fix for this soon. I’ll try to keep it updated here.

Thanks,
QA Team

1 Like

Thanks a lot for the updates, great to know this is nearly nailed!