Unity 3D

3D Environment & Lighting | Unity

A quick view of different things that can be done using Unity

Fernando Alcantara Santana
Nerd For Tech

--

Objective: View some of the different things that can be done in a 3D environment using Unity.

In the last post I covered how to create and implement a skybox in Unity. Now, it’s time to check out different things that can be done with Unity in a 3D environment.

Customize materials

With Unity, we can customize materials in different ways. As I, a game developer, needs to know how to handle the textures and meshes that technical artists create in different types of software. For example, we have the next columns:

  • The first one (left) is a model made in another software and it’s using a default standard material.
  • The second one (right) is the same model but with a customized material that provides a look as if the model was made of marble.

So, in order to give the first model a similar look as the second model, let’s customize the next properties of the standard material:

  • Shader

This option determines what type of shader the material will use. In this case, we need the model to have roughness and metallic properties, so we need to choose a different shader named Autodesk Interactive (which works similar to the standard shader but with roughness).

If you want to know more about built-in shaders you can visit the Unity docs:

  • Albedo

This option determines the base color or the base texture of the material. In this case, we need to select the respective texture of marble from the project folders by clicking in the point at the left of the parameter.

If you want to know more about the Albedo parameter you can visit the Unity docs:

  • Metallic

This parameter determines how metal-like the surface of the material is. If the material is more metallic, the reflections of the environment affect the surface more.

If you want to know more about the Metallic parameter you can visit the Unity docs:

  • Roughness

This parameter determines how the light reflections are handled by the material. As opposite from the Smoothness parameter, the Roughness makes the reflection of light bounce in a wide range of angles from the surface.

If you want to know more about the Roughness/Smoothness parameters you can visit the Unity docs:

  • Tiling

This parameter determines how many times will the texture of the material repeat in a horizontal and vertical way to fill the model.

This way, we are able to modify the aspect of the models by using materials with several different properties to optimize the look of our games.

Model with different materials and meshes.

For example, another property that we can modify in the materials to give more detail to a model is the Occlusion. The Occlusion property determines which areas of the model should receive indirect light. To customize a material with Occlusion, we need to provide a texture map:

As you can see in the next gifs, when we modify the level of Occlusion using the texture map, the door model (right) displays “fake shadows”:

If you want to know more about the Occlusion parameter you can visit the Unity docs:

Lighting

Let’s talk about another important topic, the Lighting in Unity. There are 2 principal ways to handle and display the changes in light with Unity.

We have the next scene with a couple of primitive gameobjects, a cube and a sphere. The cube has a customized material that emits baked light using the Emission parameter.

Let’s open the Lighting tab by going to Window > Rendering > Lighting:

Enlighten Lightmapping

In the first place, we have the Enlighten lightmapper (which is deprecated). If we choose to use this way to handle and display the light changes in the scene we’ll need to wait until the scene bakes before seeing any changes made.

As you can see in the next gif, if we move the cube that emits light to another position, the light that was baked with it will still be in the same place as before. So, by using the Enlighten mode we’ll need to wait until the scene bakes again before we can display the new light in the new place of the cube.

Baking the new light will take a lot of time:

Progressive Lightmapping

On the other hand, if we choose to use a Progressive lightmapper, we’ll be able to bake the light in real time and see the results quickly. There are 2 options in the Progressive mode, we can choose between baking the lighting with the CPU or the GPU. In general, it’s faster to use the GPU, so we’ll choose it:

In the next gif we’ll be able to notice how faster is the light baked using a progressive mode. By using it, we can distinguish the changes of light in the new position of the cube almost instantly:

Baking the light will take just a little:

And that’s it, we viewed some of the things that we can do in a 3D environment with Unity! :D. I’ll see you in the next post, where I’ll be showing how to create and implement light probes with Unity.

If you want to know more about me, feel free to connect with me on LinkedIn or visit my website :D

--

--

Fernando Alcantara Santana
Nerd For Tech

A passionate computer technology engineer and Unity developer that is always looking to grow in every aspect of life :).