Home Unity

Static lighting in Unity 2018.3

polycounter lvl 9
Offline / Send Message
RabidRabit polycounter lvl 9
Hey Everyone. I've been having a hard time really nailing down exactly what is going on with my light bakes in Unity and that may just derive from my lack of understanding of what all the light settings are meant to achieve.

 I have posted an example below to "illuminate" exactly what is happening. Notice the left image where my normals seem very defined and my roughness responding as expected. When I bake that light the normals turn flat and black while I appear to lose the roughness effect entirely.

My meshes are marked as lightprobe and lightmap static while my directional is set to mixed and my point light is set to baked. I am using the point light here for illustration but I would expect my baked lights to be acting more like the preview light but obviously baked in.

Other settings:

Deferred Rendering.
Linear Color space.

Lighting Tab:

Realtime GI (checked)
Baked GI (Checked)
Mode: Baked indirect.

Lightmapper: Progressive.
Lightmap size: (1024)
Directional Mode: Directional.
AO (Checked)

Reflection probes are also set to baked.

Reflections: 

Replies

  • Noren
    Offline / Send Message
    Noren polycounter lvl 19
    Even directional lightmaps are just a rough approximation. What you are seeing on the left picture is the specular of the omni which depends on the exact position of the light. If your omni is the strongest light, its direction will be saved, but (probably) not it's distance to each pixel of the lightmap. So basically this would work fine for directional light and less for omni lights. (I'm guessing, here, though, it's been a while). If you have a stronger light than the omni, its direction will end up in the lightmap and even the direction of the omni will be ignored or taken into account to a lesser degree.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Hey, try using the Enlighten Lightmapper setting utilizing the directional mode. On baked lights try turning the light mode to MIxed and submode to Shadowmask. I doubt you will then need as large a lightmap size. You may also be able to keep progressive Lightmapper and get those settings but I haven't tested.

    Side note: That color you used for the background of your images is freaky, looks like the image is highlighted lol
  • RabidRabit
    Offline / Send Message
    RabidRabit polycounter lvl 9
    Thanks guys, I think I finally got my search queries lined up with the actual problem. As Zachagreg has mentioned, apparently the "shadowmask" settings are the culprit. I have also switched to enlighten just for a test bake. I'll post an update if stuff works out.

    Side note: haha I just sampled some random point on the door. Going for that "IMPACT PLS HELP" effect :P
  • RabidRabit
    Offline / Send Message
    RabidRabit polycounter lvl 9
    So ya I swapped out some of my bake only area lights for mixed points with the new shadowmask settings and this appears to be working the way I expect.

    Check this out though. Only one side of my meshes are being affected by the directional light. Wat? 


  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Have you baked each one of those shots? Or just the first one? That may be the issue, that it is only holding the secondary lightmap from the previous bake. Essentially what shadowmask does is create a second lightmap specifically for specular detail. So if you didnt rebake, changing the light may change the first lightmap because the light is mixed but may not change the other.
  • RabidRabit
    Offline / Send Message
    RabidRabit polycounter lvl 9
    Sounds like that could be very possible. I just swapped that light to realtime to see what would happen, assume everything would act as if it was being hit by a real time directional again.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Yea it was probably just that the maps did not reset. Were you able to get it reset eventually?

  • Noren
    Offline / Send Message
    Noren polycounter lvl 19
    zachagreg said:
    Essentially what shadowmask does is create a second lightmap specifically for specular detail. 
    You mean directional lightmaps? Shadowmask and Mixed simply renders the specular detail in realtime, at least to my understanding.
  • RabidRabit
    Offline / Send Message
    RabidRabit polycounter lvl 9
    Unity got back to me on this as well: "The glossiness calculation needs a view vector. You can tell by the highlight changing shape based the viewing angle of the camera. This information is not there anymore after the light has been baked, as there's not a pre-defined point of view in the scene when baking the lightmap. If you want this effect, you'll have to use either realtime lights, or mixed lights. For mixed lights indirect bounces are baked, but direct lighting is still calculated at runtime. You need to pay the cost of realtime lighting, but you get the view dependent specular effects. You can't move the light anymore, though."

    I also crunched a bunch of videos on Unity specific lighting from Brackeye's and Sykoo so I think I have a better understanding on what exactly was happening. I guess for whatever reason I never had much of an issue when I was using UE4 so I never really dove into what is actually happening with the lights. I'll post up my results after I go through and groom my scene again.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Noren said:
    zachagreg said:
    Essentially what shadowmask does is create a second lightmap specifically for specular detail. 
    You mean directional lightmaps? Shadowmask and Mixed simply renders the specular detail in realtime, at least to my understanding.
    That is most likely the case, the documentation is a little unclear on it from what I was reading. It states the near camera meshes are baked in one lightmap and the far ones baked in another so I probably misunderstood that.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Hate to double post but I can't seem to edit right now. As an edit to what @Noren said you are correct, I found some more information on this essentially near camera objects and lights receive realtime lighting while the far camera objects receive high quality baked lighting which also includes shadow detail from near camera objects. 

    In terms of Rabid what Unity told you is essentially what you've done by using Shadowmask since the light is now in mixed mode. So that is why your light no longer affected the other side of the wall, due to the baked lighting. Doesn't really explain why your maps didn't reset on movement. Try going to the Generate Lighting and there should be a drop down on that button and set it to Clear Baked Data.
  • Noren
    Offline / Send Message
    Noren polycounter lvl 19
    Might be a term confusion. Shadows of meshes closer than the (shadow?) distance are rendered in the shadow map (realtime), those further away are taken from the (previously rendered) Shadowmask. Not sure if the direct lighting + specular is affected by the distance simultaneously, might make sense.

  • RabidRabit
    Offline / Send Message
    RabidRabit polycounter lvl 9
    zachagreg said:
    Hate to double post but I can't seem to edit right now...

    I thought that was just because I was using Mobile haha. Weird, polycount must be playing around with their forum features.

    Thanks guys. I'll mess around with the baked data stuff. 

    I do find it rather strange that they have all these reflection probes/light probes to make static lighting an option yet it dunks on your pbr materials by spitting out your normal maps as flat and basically eradicating your gloss maps simply due to a lack of any realtime light vectors.
  • Noren
    Offline / Send Message
    Noren polycounter lvl 19
    Well, if you put all that information in the map and add the camera position to use it for rendering realtime specular/gloss, it's probably easier and more resource friendly to simply use the existing light, which they offer as an option.
    Reflection and light probes are a different story. (You could experiment with using reflection probes for your walls, if that's possible, but it would require a lot of trial and error and I'd guess a realtime/mixed light would probably still be cheaper.)

Sign In or Register to comment.