In this tutorial we will go through the first steps of setting up the Cornell box model in Unity. We will mostly focus on how to add different lightnings and other effects into the room. The blog posts describes the settings required in Unity in order to receive these effects. We will guide you through the steps of how to create not only sunlight, nightlight and spotlight, but also soft edges, ambient occlusion, rotation and colouring. All of the feeds until ”Creating soft edges” are basic steps for all of the effects. Hopefully you will enjoy it!
To set up the scene in Unity, go to this website and download the two resource files. Open Unity and drag-and-drop the files into Assets below the scene and then click on Import in the pop-up window. Double-click at ”CornellBox” with the Unity icon and then delete the 2DCamera seen on the left panel. Press the play button in order to receive this image below.
To see the room from the front as in the Game view, you can adjust the Scene view with the x,y,z-axes on the upper right corner until you receive the image below.
In order to get started with the lightning of the room, mark Plane in Cornell tab on the left panel and choose Standard in Lightmaterial seen in Inspector. Extend the tab Lightmaterial and change the value of Emission to 40 and Global Illumination to Baked. In the menu bar, click at Window → Lightning → Scene and mark Continious Baking box at the bottom of the panel. Also, edit the value of Indirect Intensity from 1 to 0.5.
By clicking on Camera3D and changing the Rendering Path in Inspector to Forward and the Depth value to -1, you will receive this image below.
As you can see in the picture above, there are some jagged edges on certain areas of the objects. To smooth out those edges click on Edit → Project Settings → Quality where you choose the level Fantastic and set the value of Anti Aliasing to 8x Multi Sampling. All of the following posts are proceeded from this step of the tutorial.
One way to make the room get an warm welcoming light, is to recreate sunlight in Unity. This can be done by clicking on GameObject → Light → Directional Light where a new light source will appear. If you would like to add shadows, choose a Shadow type in Inspector. Relocate the light source and adjust the direction as you wish by rotating it. The direction of the light source is pointing along the z-axis. In order to see the effect of the changes in real time, unclick the Continious Baking box.
If you would like to add nightlight into the scene, click on GameObject → Light → Directional Light where a new light source will appear. If you would like to add shadows, choose a Shadow type in Inspector. Thereafter, click on Plane and change the Emission to 20 in Inspector and then uncheck the Continuous baking box. Mark the Fog box in Lightning and choose the Fog Color and Density value as you please. In our example we have changed to a darker grey-black color and the Density value to 0.125.
Another type of light you could add to the scene is a spotlight. Go to GameObject → Light → Spotlight and replace the coordinates of the Spotlight with the coordinates of the Plane. Furthermore, drag the Spotlight into the Plane in the left panel. Mark Spotlight and change the values of Range, Spot Angle and Intensity to for example 10, 50 and 7 found under Inspector. To receive this image below, turn on Fog with the values given in our previous feed.