How to make a fake interior effect with Unity using reflection probes.
If like me, you have played or seen the latest Spiderman gameplay you are probably wondering how those magical interior effects work. But did you know you can replicate a the same effect with Unity only using build-in components? This is what I will try to explain in this tutorial.
For this project I’m using Unity 2018.1 but you can use any version from 5.x to 2018.x, even though I’m not entirely sure if it’s working or not with the new scriptable pipelines.
Before we start, you need to make sure the Reflection Probes Box Projection option is enabled in the project settings.
If not, go to Edit / Project Settings / Graphics, uncheck the Use defaults option and check the Reflection Probes Box Projection on all the tiers.
We are now ready to start, I’m using two 3D models made with Asset Forge, one for the interior and one for the exterior with a few color variations. Start by placing all your models inside the scene.
You can find the project files and assets in the link below.
Before we go any further, make sure your models are statics (click on the Static button located on the top right corner of the inspector) and that you selected all your models in the Hierarchy.
Next we need to flip the interior models.
If you are wondering why, it’s because like in the real world, the reflection made by a mirror (here our probes) is reversed.
Select your exterior models in the Hierarchy and scale it to -1 on the Z axis (forward).
Now we can dive into the core of this tutorial: the reflection probes.
Right click inside the Hierarchy > Light > Reflection Probe, place the reflection probe you created inside your interior model.
Check the Box Projection option inside the Reflection Probe inspector.
Click on the Size button on the top of the Reflection Probe inspector and move the bounds (the yellow box) as close as possible to the interior walls, ceiling and floor.
Then click on the Origin button on the top of the Reflection Probe inspector and move your probe where your window stands.
Repeat those steps for all the remaining windows.
If you think your interior is too dark you can add multiple types of lights.
Right click inside the Hierarchy > Light > (as you want).
I’m using Area Light for windows and Point light as ceiling lamp.
Now the light and reflection probe part is done, we can now bake the lightning.
The next step is to create a quad for each of the windows, Right click inside the Hierarchy > 3D Object > Quad, move and resize the quad in a way that it entirely hides the view.
The window needs to be 100% reflective, so we are going to create a new material.
Right click inside the Project panel > Create > Material, set the Metallic and Smoothness parameters to 1. And finally, drag and drop this material on your window to apply.
Because I belong to the lazy type of developer, I created a script to duplicate the reflection probes from the inside house model to all of my windows.
The script is pretty easy to understand: you pass the reflection probe as parameter and the script duplicate and move the reflection probe at the right spot.
That’s it, if you play the scene, the fake interior effect works as if by magic.
This method is quick and easy but as several cons, for instance, if you rotate one of the windows, you are going to notice that the reflection breaks, this happens because the cubemap (the 360° image) made by the reflection probe only has a fixed rotation.