Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Lighting Interiors In An Open World Scene

Discussion in 'High Definition Render Pipeline' started by Joshd1410, Jul 29, 2022.

  1. Joshd1410

    Joshd1410

    Joined:
    May 7, 2021
    Posts:
    35
    I know this topic has come up here before because I've previously found posts on it but I can't seem to find them again...

    When placing a building into a scene with some exterior lighting setup (currently directional light + hdri) why is the interior of the building always fully lit?

    The only way I've been able to get the effect of having the interior appropriately dark given the lighting setup is by baking lightmaps. However, for a reasonably large open world scene with many interiors this isn't practical. Recently I watched a video on the subject which basically said to forget baked lighting altogether for large open world scenes and just use realtime lights. I can see the logic given the bake times are already too high with 1-3 buildings. If you do this though how do you get interiors to actually be dark? It just seems that they're always lit the same way no matter what you do.

    I've tried using local volumes. Sure they darken the interior but a) only while inside and b) the transition is too jarring.

    Another issue I'm having is that the ceiling of a building, which is supposed to be white plaster, is actually a brown colour. I can only assume that this is reflecting the bottom part of my HDRI perhaps, but why? And how do I get it to stop happening?

    I'll be the first to admit I'm a lighting noob. I've spent a while trying to figure this out but I'm getting nowhere.

    Summary of questions:
    1a) why are interiors of buildings fully and uniformly lit?
    1b) how, if at all, can I get them to not be fully lit without baking lighting?
    2) why are ceilings reflecting my hdri?
     
  2. Joshd1410

    Joshd1410

    Joined:
    May 7, 2021
    Posts:
    35
    Just to show a bit more clearly what I mean here is two screenshots of similar rooms. Material assignments are the same for each room apart from the carpet is different. The first one I just threw together and got this setup in about 2 minutes in a new BIRP project. No baked lighting.

    Second one is my current HDRP headache.

    All I had to do to create this first image in BIRP was set shadows of ceiling/floor piece to double-sided which instantly occluded the whole room then just positioned a directional light outside and point light inside. Sure it could look better but I'm quite shocked how easy it was in built-in considering I've spent days in HDRP baking lighting and tweaking things just to try and get this same effect.

    One other key to this was killing skybox lighting and lowering reflections. Very easy to do in built-in given that it's all actually IN THE LIGHTING TAB where it should logically be.

    Anyway mini-rant over, what am I missing with HDRP and how can I achieve this exact effect without baking lighting please?

    DarkRoom.png HDRP.png
     
    Last edited: Jul 29, 2022
    valarnur likes this.
  3. pierred_unity

    pierred_unity

    Unity Technologies

    Joined:
    May 25, 2018
    Posts:
    433
    Hey, no worries, what you see are fairly common head scratching issues for newcomers or beginners in lighting. ;)


    HDRP uses a fallback mechanism for the diffuse (your "bounce light") and specular lighting (your reflections).

    For diffuse lighting, if you don't have any Screen Space GI, nor Lightmap/Light Probes, it will fall back to the sky's Ambient Lighting, calculated from the sky. This is why your interior receives a lot of unwanted lighting from the outside by default.

    See the doc for ambient lighting, and how you can decouple it from the visible Sky:
    https://docs.unity3d.com/Packages/c...ual-environment-from-the-lighting-environment

    It's a similar story for reflections: if you don't have Screen Space Reflections nor Reflection Probes, the reflection will fall back to the one generated from the visible sky. And again, because you don't have any of the first 2 ones, that bright sky will leak inside your interior.

    See the doc for this concept of Reflection Hierarchy/Fallback:
    https://docs.unity3d.com/Packages/c.../Reflection-in-HDRP.html#reflection-hierarchy


    If you absolutely don't want to bake anything, you can use the Indirect Lighting Controller, which lets you control exactly how objects are affected by this ambient light (both diffuse and specular), per light layer.

    See the doc for the Indirect Lighting Controller:
    https://docs.unity3d.com/Packages/c...al/Override-Indirect-Lighting-Controller.html

    See the doc for the Light Layers, to control which lights affect which objects:
    https://docs.unity3d.com/Packages/c...high-definition@14.0/manual/Light-Layers.html

    I've had a quick test in the HDRP Scene Sample project (you can create one from the Unity Hub), and it works as expected, I can control exactly how much ambient light affects the "InteriorOnly" light layer, and the changes do not impact the exterior world:
    upload_2022-7-30_2-23-14.png

    And without any of these changes, this is what someone would see if they don't bake anything at all (similar to what you see in your level), unwanted skylight and sky reflections:
    upload_2022-7-30_2-25-9.png

    With this technique, you'll need to be careful about dynamic objects moving between interiors/exteriors, as you'll need to make sure their light layers are set correctly based on the situation (via scripting); and ensure objects' light layers are all set properly.

    Note: the indirect lighting controller will also influence the SSGI, if you wish to use it.


    See my answer for 1a), it's because of the fallback hierarchy and the lack of local Reflection Probes.



    Of course, with all these techniques, because you don't want to bake anything (at least in Unity), you'll only have a fairly flat ambient lighting. You'll need to rely on fairly strong SSAO to get some indirect lighting definition in your interiors, or AO maps or other info you may bake in another software. You can also mix SSGI + SSAO + Indirect Lighting Controller + even Realtime Reflection Probes (we offer time slicing now, so they can now be much cheaper than previously).

    And setting up your Exposure correctly will be important too to handle indoor/outdoor transitions (especially the Limit Min/Max properties):
    https://docs.unity3d.com/Packages/c...definition@14.0/manual/Override-Exposure.html


    There are ways to use baking for larger worlds, but it requires a lot of discipline with light maps, and it forces you to maximize the usage of probe-lit objects. I'm certainly not saying it's easy, and depending on the size of your level, bakes might still be fairly long. And if you want a day/night cycle, that's even more difficult.

    There is also Realtime GI if you want to go down this route (here's a tutorial to optimize baking times: https://learn.unity.com/project/lighting-optimization-with-precomputed-realtime-gi), or you could use Raytracing (but the performance cost or the platforms you target might not allow for this).

    Tldr: There are many ways to tackle this, it all depends on what you're looking for (quality vs iteration time), but the solution I gave you at 1b) might suit you better at first if you're a lighting beginner.
     
    Last edited: Jul 31, 2022
  4. DrMeatball

    DrMeatball

    Joined:
    Nov 21, 2021
    Posts:
    106
    Ty for this post and the response above! I'm always on the lookout for issues I'm going to run into myself and this is most likely going to be one of them.

    If I'm reading right, I gather what pierred_unity posted is a potential solution to what the OP posed and how they'd built their scene. My question, as an extension, is there a preferred/recommended way of lighting an open world interior if OP's isn't the ideal method?
     
  5. Joshd1410

    Joshd1410

    Joined:
    May 7, 2021
    Posts:
    35
    Thanks for the detailed reply. I've managed to get quite a lot of progress based off this information. Really appreciate it!

    I am still having an issue with lighting interiors though it's a slightly different one to the original now. I've decided to try going for a mixed approach as you suggested so am using some baking in interiors.

    For some reason I'm getting these weird artefacts on random parts of the scene now. They're visible in both the light and dark images below. Strangely they disappear when I move the camera closer to them so I assume there's some kind of screen space effect which takes them out at certain distances. However they're very visible in game for a while before this effect kicks in so I want to do something about them.

    I think the images below explain it best. Same scene with lights off/on and slightly different camera angle. The line of light in the first image is the room corner with the weird white glow in the second image.

    I assume this is down to lightmapping somehow but I've played around with some settings and so far nothing has helped. Granted I don't really know what I'm looking for though.

    Lighting.png Lighting2.png
     

    Attached Files:

  6. pierred_unity

    pierred_unity

    Unity Technologies

    Joined:
    May 25, 2018
    Posts:
    433
    It could be lightmap related indeed (like overlapping texels), because for instance these meshes are not unwrapped correctly, your texel density is too low, the denoiser is struggling, etc.

    To isolate this, you can switch to this debug view, after you baked the lighting:
    upload_2022-8-3_11-14-38.png


    If it's unrelated to lightmaps, go to Window > Analysis > Rendering Debugger.

    Then go through all the options for Lighting Debug Mode, and Fullscreen Debug Mode, as well as trying to Override the different materials properties (Albedo, Normal, etc.).

    upload_2022-8-3_11-9-7.png

    You can also view specific material properties this way:
    upload_2022-8-3_11-11-8.png


    We do have a channel dedicated to baking/GI btw, you might find more help there, if you're issue is not HDRP related: https://forum.unity.com/forums/global-illumination.85/
     
  7. Joshd1410

    Joshd1410

    Joined:
    May 7, 2021
    Posts:
    35
    Excellent, thanks. I'll be sure to check out the GI forum too.

    I actually managed to overcome this issue by increasing the resolution of the shadowmap for the directional light.

    I have one final question about something you mentioned in your first reply: when using the global volume to only influence the interior's indirect and reflection lighting, is there a standard way I can also control the exterior separately? Or even have individual control over each light layer? I'm currently using two global volumes for this, with the second one only having an indirect lighting controller for the exterior. This sort of works but when loading the project up I always have to disable/re-enable the volumes in some certain order to get them working properly again.

    Is there a way I can use multiple volumes to have absolute control over individual lighting layers indirect lighting without each volume having any influence on the others (if that makes sense)? I thought maybe the "Weight" setting would do this but if I set it to below 1 on the main volume it unbalances all other already set effects such as exposure (blending with the default volume profile settings I'm guessing?).
     
  8. pierred_unity

    pierred_unity

    Unity Technologies

    Joined:
    May 25, 2018
    Posts:
    433
    You can use the Priority property on the Volumes to ensure they don't fight each other. If 2 volumes override the same settings and have the same priority, the order of their activation (usually based on the position in the hierarchy) will dictate which one "wins" over the other one.

    Having a "mixer" to control the lighting influence on each light layer would be something nice in theory. However, this becomes a bit of a nightmare to manage for less experienced users. Plus it also becomes tricky for the Lightmapper, raytracing effects, screen space effect and reflections to handle this seamlessly, as they may all interact with each other (and ultimately it's only a camera effect, not a true localised dimming of the lighting). If we ever do such a system, it might need to live outside the volume system.
     
    Last edited: Aug 5, 2022
  9. Joshd1410

    Joshd1410

    Joined:
    May 7, 2021
    Posts:
    35
    I'm not sure if this is a bug then or if it's intended, but it seems only one volume at a time can actively override the default indirect lighting settings. I currently have:

    Global volume with priority 3 with indirect lighting override controlling light layer 1 (interiors)
    Global volume with priority 2 with indirect lighting override controlling light layer 0 (everything else)

    However, the override on the second volume does not apply at all with these priority settings. Changing the weight of the first volume to 0.99 causes the second volume to take effect but on all light layers despite being set to only affect light layer 0. Also the indirect lighting multiplier must be set to a very high value.

    I have found a way to control indirect lighting for two lighting layers though, so if anyone is interested in this in future here it is:

    Find the DefaultSettingsVolumeProfile in the HDRenderPipelineGlobalSettings
    Add an indirect lighting controller to this profile & set the light layer settings for the first layer you wish to control
    Add an indirect lighting override to your global volume and set the settings for the other light layer you wish to control

    This works for now and gives me a nice level of control over the interior and exterior indirect lighting separately so I'm pleased :)
     
  10. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    Alright @pierred_unity , I'm facing the exact same problem as the OP and though I've tried the solutions outlined in this thread, I am failing to make any progress. It must be something stupid simple that I am missing.

    I have a relatively simple scene, with a small room made of cube primitives. A single directional light illuminates the scene. No matter what I do, occluded geometry is fully lit, as if the roof and walls are not even there. Notice the small sphere that is also receiving light and casting a shadow.

    upload_2022-8-27_12-40-38.png

    upload_2022-8-27_12-40-58.png

    Light Probes:
    upload_2022-8-27_12-43-31.png

    Reflection Probes:
    upload_2022-8-27_12-44-34.png
    upload_2022-8-27_12-45-21.png

    The occluded faces of the walls and ceiling look great, but the floor and opposite walls are completely lit. Any idea what I'm doing wrong?

    Here are the relevant config that I can think of:
    1. Version 2021.3.6f1, HDRP 12.1.7
    2. Directional light is set to Mixed
    3. All light layers are set to default
    4. All walls are set to Static with GI from lightmaps
    5. Interior and exterior of the room is light- and reflection-probed
    6. The material is a standard HDRP/Lit shader, with white color only
    7. Neither double-sided shadows, nor single-sided shadows on the walls change the result
    8. Sky Reflection is turned off in the default settings
    9. I have a global volume with dynamic ambient, and a local volume for the reflection probes with static ambient
    I appreciate the help!
     
  11. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    You need to bake lightmaps. On top of that, make sure your global post process has visual environment set to static, and is correctly assigned in environment tab (found in lighting settings). Create a new post process volume, set sky, and assign it there.
    Then you need to bake reflection probes after the bake.

    It looks fully lit because if you don't bake lighting, sky lighting is applied to everything.

    Wish unity has sky occlusion, would help a lot in general. It's annoying having to place reflection probes as well.
     
  12. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    @PutridEx thanks for the feedback! I forgot to mention that I am baking the lightmaps and the screenshots are the result. The reflection probes are in there as well, which is why I was getting confused; I thought I had everything set up correctly.

    What I did find, however, is that switching from Baked Indirect to Shadowmask in the lightmapper then allowed the shadows to be baked. Is that intended? When I watched the Unite 2020 Lighting tutorial it seems as though Baked Indirect should do both indirect light as well as shadows... but that doesn't seem to be the case?
     
  13. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Weird, are your lights set to mixed? If they're, the shadows are real-time so make sure your lights have enabled shadows. And your objects are static + set to contribute to lightmaps.

    Could also be the exposure, worth checking that out
     
  14. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    I'm not sure if it's correct or not, but Baked Indirect doesn't look like it bakes shadows, nor are mixed lights shadowed in real-time. A similar issue was brought up in this post. What solved it for me was baking in Shadowmask mode, with all lights set to Distance Shadowmask. Hopefully this helps someone in the future.
     
  15. pierred_unity

    pierred_unity

    Unity Technologies

    Joined:
    May 25, 2018
    Posts:
    433
    Your problem is different than the OP. ;)

    For whatever reason, your building made of cubes doesn't cast real-time shadows. It doesn't matter if you bake lightmap or not, these cubes should be able to cast shadows. There's clearly some setup issue on your end if the sphere can cast shadows, but the cubes don't.

    Also, shadowmasks are only hiding the issue about the lack of real-time shadows on your objects (Shadowmasks are replacing real-time shadows), so it's not really a correct solution to your problem (plus shadowmasks only support 4 shadowing lights per texel, so it may become very limiting).
     
    Last edited: Aug 29, 2022
  16. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    Thanks for the feedback. There was clearly something wrong and to be honest, I'm not sure what it was. I just opened the editor back up, changed the lighting mode to Baked Indirect, resized the walls, cleared baked data, and remapped. Now everything is working...

    upload_2022-9-3_10-53-4.png
     
    pierred_unity likes this.