The Exciting World of 3D Environment & Lighting in Unity!
Now that I am starting a new project and moving from 2D to 3D, my objective for this article is to polish up some game assets by creating and assigning materials and textures, as well as talk a little about lighting.
My first task is to get the basic pillar object on the right looking like the finished one on the left.
I start by right-clicking on the Materials folder and selecting create > material. I name it Black_Marble_mat.
Right under the name in the inspector, the Shader is changed from the default Standard to Standard (Roughness) for some added texture. The small circle next to the Albedo is selected and a drop down appears for me to choose a texture to add. I have a nice black_marble texture at my disposal so I choose that one. The Metallic property dictates how reflective something is, with a value of one being completely reflective, and zero having no reflections. The Roughness property similarly holds a value range between zero and one for how rough or smooth something is, with zero being completely smooth. Increasing the Tiling property to four from the default of one will increase the density of the texture map as it appears on the 3D model. The bottom of the image shows a preview of the material.
The new black marble material is now dragged from the materials folder into the Materials array variable in the Element 0 position on the MeshRenderer to assign it.
The plain pillar is now looking much better!
The next object to receive this special treatment has sub-meshes, which lets me assign multiple materials on the same object that will show up in pre-specified locations on the mesh.
I already have a black marble material, so now it’s time to create a white marble counterpart.
The white marble material uses the standard shader. It also gets some roughness and a decent amount of reflectiveness via the metallic property.
A white marble texture is assigned by using the Albedo channel.
Now both marble materials can be assigned to the different material elements in the inspector.
There is a small gold diamond décor piece which needs a new gold material.
The most important things for the gold material are color, metallic and roughness values. Because gold is metal and this is a very polished piece, not some crude gold found in the dirt, I give it full reflectiveness and smoothness.
The sub-mesh can now take the gold material assignment.
Both columns are now looking pretty finished!
Next up is this wall section with all three of the new materials created, as well as a painting.
Each sub-mesh will need it’s own respective material assignments.
The Gold Decor sub-mesh takes the same gold material I just created for the diamond shape on the column. The Painting Rim sub-mesh gets the same gold material assignment.
The Painting Wall gets can take three materials for it’s respective sub-meshes.
For the painting, I create a new material called painting_mat, and assign a 2D image of a painting as a texture via the Albedo channel.
The painting material can now be assigned to the painting sub-mesh on the wall object.
Here are the two painted walls together with different paintings.
Now we come to a set of double-doors.
Both door handles will get the same gold material as everything else.
The door portion of the mesh gets this door material, which is mainly just a little roughness with an nice Albedo texture assignment and an Occlusion map.
A close up of the Albedo texture shows the 3D model stripped down to 2D by breaking it apart and laying it flat. Textures are a fantastic way to get more visual appeal out of a 3D model while keeping it low-poly.
The Occlusion map works in a similar way, only occlusion works with light. White areas will receive full indirect light, while black areas will ignore indirect light. Using occlusion maps can really give shadows extra depth for a deeper more refined look.
After assigning the door texture, both doors are looking pretty good!
Now let’s get into a little about lighting, and that can be done through the Emission channel, which enables an object to self-illuminate. The emission channel lets the object gather light data from a texture or a color rather than a lighting source. I select a wood and glass display case in the scene view and then navigate to the Emission channel in the inspector.
Here I drag the emission value up to increase it, and down to decrease it.
You can see the power of light emissions in the gif below!
Let’s finish up by going over two different lightmapping settings. Start by navigating to Window > Lighting > Settings. When using Enlighten in the Lightmapper settings, the lighting information in your scene won’t show until the lighting is done baking. Depending on how fast or slow your computer is, this could take a while.
When it’s important to get visual lighting information back faster for game design purposes, the Progressive preview option comes in handy. This selection will begin to update your lighting information before the scene is finished backing, which let’s the design get back to designing and making decisions quickly.
In my next article I will dive back into materials and make some glass! Thanks for reading!