TUTORIAL # 1 _ Setting an ambient with baked GI (Unity 3d)

The room that we will build up in the tutorial

The room that we will build up in the tutorial

 

IMPORTANT NOTES BEFORE STARTING

This is NOT a modelling tutorial. Here it's presented a fast overview of the baked workflow for rendering an ambient using some free (and some payed options) 3D models and assets. In order to get a real professional look in your work you will need to properly prepare models and setting for your purpose. This tutorial is intended for BEGINNERS that have a basic knowledge of Unity interface and workflow. The room in the photo is NOT for portfolio purpose, so it's quite simple and has very few furnitures and accessories. Everything is made in a simple way in order to let you finish all the scene in around 30 minutes (excluding baking time).  

 

GET THE PARTY STARTED...WHat we will do?

We will create a small room in order to understand a little bit how models, lights and post-production work in Unity 5. First, let's check which software we will use and how to get them.

  1. UNITY3D 5. The core of our tutorial, it can be freely downloaded with a Personal authorization. Install the latest stable version. For this tutorial I used the 5.4.3. 
  2. SUBSTANCE SUITE. Substances are a great source for texturing in Unity: they are procedural, can be tweakened inside the software, are supported as native add-on, they are fast and they look great. The suite is composed of 3 softwares: DESIGNER, for creating procedural substances, PAINTER, for painting models and export textures, B2M, a tool that let you to create textures from photos. 
  3. MAYA LT. A modelling software is very usefull and MAYA from Autodesk is great. The LT version is made for game developers, so it's a great pack with an high Price/Quality ratio. A totally free alternative is BLENDER.

WAIT! THEY ARE EXPENSIVE?

Substance Suite and Maya need a subscription, but they are extremely flexible. First of all, an amazing thing for young developers is that they both have an Academic License totally FREE. You can ask, showing your inscription to a certified institute, a free account that let you use these programs without any charge. If you are not a student, they come with monthly or yearly subscription (MAYA LT subscription and SUBSTANCE LIVE) with an affordable price. Moreover, they have also a 30 days trial with full features enabled. 

 

Another caption of the room

Another caption of the room

MODELING THE ROOM

Create in your modeling software a small room, better if you insert fake corridors as in the photo above (just to see how light react in a shape different from a simple cube). This is not a modelling tutorial so you can easily check extended information in detailed books or videos about that. For now, make something REALLY SIMPLE. You can start from one wall, create one or more windows according to your taste, then make the other thing. Create also an external structure for a correct response of shadows inside Unity, and UV unwrap everything. Even if this function isn't the best for a correct model unwrapping, if your room is simple enough you can also Freeze Transformations inside Maya and go for Automatic UV unwrapping. Really important is to set the materials for your surfaces, especially if your room is a unique 3D model (and it should be, or one model for the inner room and another for the exterior). Go to Hypershade inside Windows -> Rendering and create two different materials, one for the Walls and one for the Parquet. Then, inside Maya, select inside the modelling Tool the FACE option and select all the faces made of Wall material, click Right Mouse and assign Existing material -> Wall. The same for the floor, using Assign Existing Material -> Parquet. Now, we assigned all the materials, unwrapped the UVs, let's go to Unity. Our last step is to export the model: we can use .fbx export option, and we have two different ways to get the model inside Unity. The first is to select, inside Maya, Export All or Game Exporter. In this way we will create an FBX model that we will be able to import inside Unity. The other way is to use "Send to Unity" option: in this case you must address the export inside the Unity Project folder, so, if you want to use this workflow start creating Unity project.  

SUGGESTED READING for this topic

 

SETTING UP THE UNITY PROJECT

Everything start from a new Unity project. Create a 3D project and keep in mind where you will save it, as for the "Send to Unity" workflow inside Maya you will need to reach the correct position inside your Asset folder into your project. Now, let's start setting up the project. Go to EDIT -> Player setting and select "Deferred" and "Linear". We can discuss about these two elements for a long time, but the most important thing is to read carefully all the documentation that Unity manual provide about these two topics. It's really important to understand those elements and I strongly suggest you to go through this documents as soon as possible. However, here we choose the rendering pipeline with the color space. We are working in Deferred Linear. 

Now, let's import our FBX appartament inside Unity project. Once the fbx has been imported inside the project, click on it and inside the inspector toggle on "GENERATE LIGHTMAP". In this way Unity will optimize the model for our future lightmap. Check that AUTO option is on, and leave it. Inside the WINDOW menu, click on "Lighting". Here we have few jobs to do: first of all, check that Baked GI is correctly ON. Set Ambient to Baked. Let's download and import a package free from Asset Store called Skybox 5x. Once imported, inside its folder, go to Skybox prefab and put it inside Skybox reference of Lighting menu. Let's go back to the scene: we have our appartament, and a default Directional Light and a camera. Directional Light work as Sun; as for the rendering topic, I strongly suggest you to read the Light part of the manual. 

For now, try to adjust the Rotation values inside the Directional Light transform, checking directly inside your house FBX how the directional light changes. We will use it to give the beautiful sun that will come inside from our windows. As it work as sun, if you will change position nothing will change. Just play with the rotation values. Once you are happy with the result, let's make it magical: there is a great toggle inside every gameobject. STATIC, with several option. For now, let's make it on both in our appartament fbx and our directional light. As we already checked the Auto option, Unity will start to bake the lights. You can see the process through a blue bar on the bottom right of the screen. When the process is finished you will be able to see the result. Now, let's add the Ambient Occlusion inside the baked process: inside the Lighting windows click on Ambient occlusion and play with both the values in order to get something that will make you happy. 

In order to avoid unpleasant result, uncheck the "Compressed" toggle and play with Baked Resolution value. For this tutorial, I kept 50 texels per unit for the Baked Resolution with a 1024 atlas size. These settings must be checked for each project in order to get a good balance between size of the lightmap and results. For now, as our room is very small, I kept the value of 2 texels for the Baked Padding. 

RENDERING PATH on unity3d manual
Lighting overview on unity3d manual
Types of light on unity3d manual
GLOBAL ILLUMINATION ON UNITY3d manual

Everybody love design!

As I wrote at the beginning, this tutorial doesn't want to show how to make a professional architectural visualization: it's just a fast experiment for beginners inside the baked GI lighting process. So, we need to populate with some furniture our small appartament. We will do something that it's not the best for gaming process but that sometimes happen: we will force us to use models intended for high-res rendering and we will try to implement them inside our scene. For that we will use an amazing website: Dimensiva. With a free subscription we will be able to download incredible models of famous designers including furniture and accessories. Just download what you want and look inside the zip for the original model. Now, most of these models are really high res and they will drop down hugely our framerate thanks to polycount. So, we will do something that for this tutorial will be enough even if for a polished professional game should require an accurate retopology procedure. Inside Maya LT, take the model and select "REDUCE". In this way, you must tune the percentual reduction of polygons; you must watch carefully for a solution that will not dropdown too much the model, make too many artifacts. Use also the soften edge option inside Mesh Display. Once the model is ok, let's export it as for our appartament. 

Please Note: check the "Modeling inside Unity3D" section of the tutorial for utilities that can reduce polycount inside Unity3D.

PAY ATTENTION!!!! As Dimensiva website states, there are really important Legal Notice inside each model. So, read them carefully. For this tutorial we used those model only for EDUCATIONAL PURPOSE, NOT COMMERCIAL. 

MATERIALS ARE EVERYTHING!

In order to get a beautiful model, you need beautiful materials. Substance will help us. You can find several pre-made substance materials inside Substance Share, Substance Source (with a monthly ammount of downloads thanks to the Live subscription) or through Asset Store. There are also several function to make parquet and tiling elements, both in Substance Designer workflow and in Asset Store or in downloadable substances. Let's use, for example, this free asset or, if you prefere, also a payed Wooden collection from Allegorithmic. You can also choose to make your own wood pattern through designer, you can find several tutorials. So, as it's really fast, for now we will create a basic wall substance in less than 15 seconds, in this way we will start to know a little bit Substance Designer ambient. 

 

Open Substance Designer, create a new substance with Physically based workflow and name it as you want, "Wall" for example. Now, we need to feed four output. Inside the base color we must put the main color of the material: inside Library search "Uniform Color", create the node and select a pure white. Now, we need to feed the normal. We can search "BnW spot" or any kind of noise, connect it to a normal conversion and feed it in the Normal output. We can use Uniform color grayscale black for Metallic channel and a very light (almost white) uniform color for the Roughness. Now, if the result is ok for us through our cube inside the viewer, let's "Publish" the substance: go to Import the sbsar file inside Unity and apply both parquet to the floor and wall to the other parts of the appartament. 

Let's do the same for the objects. I suggest you to download (or use some example substances that are already included) or make your own, according to the material that we need to simulate. For example, let's make a little bit more complex weathered leather for the sofa. Search "Leather" and import the bitmap. Import the "Fabric Weathering" patch (search it in the library) and feed it like this: convert the leather bitmap with a Gray module and put it into a Normal module, then feed the Normal input of the Weathering patch. Use black Uniform color for the base color, another black grayscale for the metallic and a slightly gray uniform grayscale for the roughness. Then, inside the Fabric Weathering patch adjust all the elements inside the "EFFECTS" dropdown menu. For a gray tissue (for example, for chair cushion and similar), you can blend a uniform color with a Fast White noise inside the Base Color node. Then blend a vertical noise with the White Fast through a multiply operation and feed the normals in order to get the movement of the tissue. Adjust roughness value and give 0 metallic though a black input.

 

STANDARD SHADER MON AMOUR

Shaders topic it's huge and as soon as someone start to understand the workflow in Unity should definitely be studied in-depth. However, let's see a little bit the Standard shader. It works with Physically Based Rendering and you can find an in-depth guide split about PBR into 2 pdfs on Allegorithmic website. Standard Shader has many features and the great thing is that can be auto-optimized: if you don't use the channel it simply disable that feature. 
Talking about shaders it would be too huge for a simple tutorial like that, but I strongly suggest to read further about, and you can also find great products that give to the node-approach (similar to Substance Designer) the possibility to create your own shaders (as Shader Forge and Amplify Shader). However, in your models there will be some part that needs very simple elements, so you can just setup the color through the direct option and adjust metallic and smoothness values in order to get a pleasant result with a really small calculation. In order to create a unique material you can also RIGHT-CLICK -> Create -> Material in order to assign it. In the next paragraph we will see another interesting thing about standard shader. 

The Bluetooth Gramophone model, with a wood substance for the base and a simple black reflective material for the upper part

The Bluetooth Gramophone model, with a wood substance for the base and a simple black reflective material for the upper part

FURTHER READINGS

 

LIGHT ME UP

Ok, we have a directional light that simulate the sun but, in this way, the amount of light is not the best. Let's spicy up things: we can use AREA LIGHTS on all the three windows to simulate the diffuse light that come from outside; this kind of light can only be used in baked workflow, but that's our case :) You can also add the models of few lights (I used some from ArchiViz asset, that I will link after) and adding some point lights to simulate their bulb source. Here you can just experiment, I kept a very simple lighting setup for a 30 minutes tutorial. 

REFLECTION PROBES

An important element for getting a correct view inside the PBR workflows are reflections. In order to get the proper reflection on objects you can use reflection probes: just click Create -> Lights-> Reflection Probe. You can setup a baked, real-time (very expensive for calculation) or custom probe. Here, just create a box that embrace all the apartment and use a baked option, checking the "box projection" option. Look at the Unity Manual for an in-depth description of this amazing tool!

Reflection probe on unity3d manual

The reflection probe inside the scene

The reflection probe inside the scene

 

Modelling procedures inside unity

One common question is: there are some ways to create models inside Unity? I need to use external softwares as Maya, 3DS Max or Blender, or I can just build up things inside Unity3D? Well, the answer is not immediate. 

In Unity you have some simple shapes. Here an example: we will create the glass of the windows just into Unity. Check CREATE -> 3D Object with RIGHT-CLICK into the scene, and select "Plane". Rotate it and scale it with the appropriate tools. Create a new material named GLASS. Into the color section you can adjust a light blue color and into Standard Shader property check "TRANSPARENT". Then, into the color, select a value of ALPHA that make your glass transparent. Then choose an high value of SMOOTHNESS (also the maximum) and play with the METALLIC value in order to get a pleasant reflection of the inner ambient thanks to the reflection probe. 

That's it, this has been created into Unity, but it's not so complex. To be sincere, inside Unity you cannot do much about modeling. BUT, there are some tools that extend its potential. 

Procore BUNDLE 

This suite can be purchased on Asset Store or on their website and it's a complete suite of modeling inside Unity 3D. Of course it can't be so complex as Maya, 3DS Max or Blender software, but for many stuff it can be pretty useful. 

advance tool megapack

This package is quite expensive BUT it's amazing. It's not a modeling suite, so it can be useful also if you use 3D software for model outside Unity. It features some physic simulations (such as Rope and Fracturing) but it has also an incredible suite for decimating polycount and create LOD (this will be part of some other tutorials). It's like a Swiss Knife if you need to work fast with huge models that come not for video-games purpose. 

POST-PROCESSING

Let's move inside the scene. You can use a static camera but I strongly prefer to be able to move myself inside a scene. For that you need to prepare the scene with colliders (in a future tutorial I will explain this procedure, for now just put a "Mesh Collider" component into the apartment and you will be able to fly into object) and Right-Click on the main "Asset" folder inside "Project View", choose Import -> Standard Asset -> Characters. Then, into First Person Character, import the prefab. 

Inside the First Person Character, choose the children component with camera and enable HDR. Then, import Cinematic Image Effects from Unity Technologies. According to your CPU and GPU, you can see a drop-down on the framerate with some effects. However, start with ScreenSpaceReflection effect, that will render the refraction on objects on the parquet, giving an incredible realistic depth to the image. Then you can add a little bit of Bloom for a more dramatic light setting and a Screen Space Ambient Occlusion for a more defined depth of the objects. In the end, for a really cinematic look, you can play with Depth of Field, simulating the different focus according to the distance of the objects. 

The final scene is ready! Simple but effective! :) 30 minutes 

The final scene is ready! Simple but effective! :) 30 minutes 

 

ARCHITECTURAL PROJECTS ON ASSET STORE

I used this room just for explain a baked GI ambient. I'm not focused on architectural project (I work more with open world environments) and this room it's quite empty in order to be able to complete everything in around 30 minutes. However, if you feel yourself really curious about photo-realistic approach to architectural rendering on Asset Store here I link some projects that can be for you a really interesting travel inside those techniques. I used few models from Archiviz Vol I for the lamp and the fireplace here :) Hope you will enjoy these suggestions: 

archiviz Pro on asset store

The asset store page for ArchiViz Pro, an italian artist that is a great expert of photo-realistic architectural rendering on Unity3D platform. He features also some collections of models ready for production. Great quality! :) 

Polybox on asset store

Another company that is specialized into architectural assets, with an high-quality rendering.

VERTEX STUDIO ON ASSET STORE

A company with some interesting asset about furniture and game-ready architectural visualization.

 

FINAL LINES: OPTIMIZATION AND NEXT STEPS

Now, we finished this simple scene. Of course, this is just the start. Once you have everything on the scene you should test the performance for fine-tuning each element. If the application run on an high-end device you can use different effects than a mobile phone, of course. Also, you can work on baking also materials and meshes together in order to reduce drawls, optimize shaders use, check where elements can be simplified. You will learn how to use Profiler and how to understand Stats inside Game view, so, everything just to remember that a lot of work should be done in order to have a scene ready to be deployed, however I hope that this little tutorial should be a good start for a more in-depth learning of those topic and a good point for move your first step into the use of Unity 3D. 

Stay connect for more tutorials! :) 

GUIDO PONZINI on UNITY CONNECT