Let’s say you have a dark cave. Outside it’s daylight (the global volume has a high exposure). You arrive at the entrance of the cave, you look inside and…
It’s bight!
You enter, and suddenly everything looks dark! (yes, you’ve entered a local volume).
This feels really weird.
How do you fix this?
Requirements:
The scene is dynamically lit (day/night cycle).
It is possible to explore the cave using a torch (dynamic point light).
Until we have this feature: Local Exposure, it’s probably not possible to do it properly. Add a fully black local volumetric fog at the cave entrance and blend it out while your local volume is blending in.
Thanks! This helps the cave look dark from the outside. However, when leaving the cave, the sunny exterior looks weirdly dark…
It’s hard to believe that Unity cannot handle that. Almost every 3D game has exteriors and interiors that are darker.
I’d love if someone from Unity could confirm that, so I can stop wasting my time. I watched @pierred_unity tutorial on the lighting and left a comment because it didn’t help for this issue.
It’s necessary to blend away the fog once you’re approaching your local volume otherwise you can’t see the outside. Some distance based blend should do the trick.
Also this problem affects other game engines too. I’ve seen caves in UE4 games that are bright from the outside too. It’s possible to get dark caves in simple non-PBR lighting, but HDRP PBR lighting is more complicated. Essentially, there is no way for the renderer to know that cave shadows should be much darker than a shadow outside.
I don’t understand – what you’re describing is standard behavior. When your camera is exposed for the exterior scene, the interior will look very dark (and the exterior will look normal). When your camera is exposed for the interior scene, it will look normal (and the exterior will look very bright).
I’ve been able to have this effect using a black fog as suggested by @koochy_rat (thanks again that was helpful).
The issue with this solution is that once inside the fog, the outside looks dark while the sun is shining.
The hack I found is to use a trigger and move the fog with player so when he looks back, there is no fog. Then stop moving it at some point… and other small hacks with a local volume so when lighting the cave with a torch it looks realistic.
I understand it is not easy to solve and affects other engines, I was just wondering what can be done in Unity. If you look at Assassin’s Creed, to name just one, you spend your time entering dark caves where you have to light your torch to see something, and with a dynamic light and HD lighting. I am wondering how they do that.
I’ve done lots of research with this and tried many techniques. In the below, I’ll break it down every step to achieve what you want. I’ll have to make two posts due to 5 image limit.
First, what you want to ask is do I want to have indirect light? It’s a tradeoff between having indirect and complete darkness.
Turn off indrect diffuse lighting.
With that, you already achieve what is desired.
With a small amount of indirect diffuse lighting, the transition might not be as obvious but you’ll have a small amount of indirect lighting.
Here’s comes the bugs and troubleshooting to get the desired results in most scenarios.
One major issue you’ll face having a local volume that will allow the interior to get that bright exterior from indoors is transition. With a large opening like a cave, blend distance with volume might be sufficient. However, if you’re climbing out a window like below, you’ll get the follow.
To do this, you’ll need to match the fog settings and other overrides that contribute to any light or artificial light to the camera for both global and local volume. The reason is so that light transition won’t become so different to the naked eye.
Lastly, if you want to have indirect light and still complete darkness, one hack solution is to add an arbitrary light where it is needed. Having one light will illuminate the diffuse so it’s not completely black. But with this you need to carefully place these lights because different exposure will create different light intensity under different circumstance.
You could script the light in a way that lowers the intensity as you enter the area.
Again, it’s how much you want between indirect lighting and completely darkness. Even the best games don’t fully utilize indirect bounce light like you think. It’s about believability like Shigeru Miyamoto once said, not 1 to 1 replica of the real world.
It’s just global, which means the exposure will be the same everywhere on the screen. So when you are outside, the entrance to the cave will be underexposed because the screen is very bright overall. When you are inside, the exit of the cave will be overexposed because the screen is very dark overall. But the exposure changes automatically as go from inside to outside or vice versa.
What Unity does not support is local exposure, that means having different exposure values for different areas on the screen so that nothing ever becomes over- or underexposed.
Looks like you did not understand my video, it is ok because the video es very basic i though it was clear, anyway, you do not need fog to achieve that, you can do it with global and local volumens with different exposures and color settings, using fog is kind of useless “hack” and also very bad for performance for just that, also with simple script you can modify those values to make a more dramatic effect
Here is an example with a better video, more like your needs, btw this is book of the dead sample from unity, i just add a local volume inside that room with some settings to make it dark, i also add a point light to simulate a torch, you can see in the second video how it looks, i did it with just 3 or 4 steps and less than 10 min, no fogs
No, because the interior was not dark enough to require a point light to see, also we could see the interior from outside. So It was not the effect I was looking for.
Yes, this is effect, thanks! I didn’t know about the book of the dead sample. I will download it and I also need to install the version 2022.2.9f1 of Unity, since I am using 2021.3.0f1. Then I will probably ask for the settings you used.
Just to save me the trouble of doing all this for nothing, do you know if the effect you are showing in the video can be achieved in older versions of Unity, or does it require a feature introduced in the newer versions?
You do not need unity’s demo to understand what i did. Basically, i’m using 3 volumes:
1 - the global volume of the scene with its own Exposure values it can be whatever settings you want
2 - i put a little volume in the entrance of that room to make a smoother transcition from the outside to the inside
3 - i put a local volume inside the room i do not need exposure values so i’m not using it, instead i’m using indirect lighting controller with lower values because is darker.
Also inside that room i put a trigger with a simple script to deactivate the entrance volume (the one i explain before) when i enter that room, i need that to maintain the bright entrance when i’m close to the door (inside) and then another outside to activate it again, now, i made this in 10 minuttes just to show you a “starter point”.
Remember even in AAA games are full of tricks because those are cheaper in terms of performance or they lack the tech and the player will not notice, do not try to achive things thinking on how real world works because you will waste time trying to create something that your tool does not have or waiting for the tech to land. The “fog hack” is also a trick but is not cheap for performance, so avoid those kind of things.
An idea: you can make a simple script attached to a trigger on that area to detect your rotation, for example if you are on a angle looking to the inside, the 2nd volume is activated and so on, that will create a more accurate effect
Also, do not use the exact values from the images, this is for this demo, you will need to ajust the values for your game…
Well, I know all the things you mentioned: local volumes, exposure control, indirect lighting control… Tried all that but there always was an issue with something. That’s why I wanted to see an example.
Also a simple question: when you are outside, the camera exposure and the indirect lighting are controlled by the global volume. This prevents the shadows to look black. so how come that the interior looks black? The camera does not know that there is a local volume there.
What would be great is if you could take those 10 minutes and create the effect in your first simple project and make it downloadable (yeah, I might be asking for too much :p, but anyway, thank you for your time, it is appreciated)
I did try this intermediate volume technique too. How do you solve the problem of the player being outside of the entrance volume looking into the cave? The entrance volume is going to have to be quite large to cover this scenario and the player is going to notice lighting suddenly changing and shadows getting darker while still outside the cave.
Sorry i understand now your point, you do not bake shadows because you need day and night cycles, sorry i did not get that before, well i did something new.
In my basic scene i have one realtime light with light layer: everything and one backed light with light layer value of 3 then, i change the rendering layer mask of my amazing house (just the house) to layer 3 then i bake and because my baked light is layer 3 is just afecting my house, then in my indirect lighting controller i can change the “indirect difuse lighting multiplier” value to match the angle of the sun, of course “indirect difuse lighting layer” is set to 3, which is the layer of my backed light
You still have the realtime shadows of the sun in the house, in this image, the indirect difuse lighting multiplier is lower, like 0.5 and is not affecting the cube because is layer 3 (you do not need an extra volume in the entrance)
You can try that as a starter point and if you move the sun and the angle is in front of the house it will affect the inside of the house as it should be.
Now, i’m not a coder so i do not know how to change the “indirect difuse lighting multiplier” value with a script i wanted to use the sun angle to change the value, i look on internet and i just found how to mess with the fog so, if you know how to do it, please tell me i want to know
I can not send you the project because this project is a "test things here) so i have many of my own assets, scripts and other stuffs here.
Again you will need a script to change the value of the “indirect difuse lighting multiplier” to match your day and night lighting and stuffs, if you know how to do it i’ll be happy if youshare it here
So you want both indirect light and complete darkness without any sort of light baking? Have you tried SSGI or RTGI? I highly recommend reading this post. Even UE5 has problems with shadows.
Can’t you push the entrance volume inwards and use the blend distance to blend the transitions?