#2 Import assets, 3D models and textures. Skybox

Updated information about this project

This article belongs to a series that consist on making a first person game about finding objects inside a maze. It’s one of my very first series from the channel. Now I reworked this project and you can download it to import in your own Unity project. Some day I will make a new series about this project, subscribe to my channel to see all the fresh content about Blender, Unity and programming.

Follow me on itch.io and download the source code of this project



YOU CAN TRY THIS GAME HERE, IT MAY TAKE A LITTLE WHILE TO LOAD
🔻

MOVEMENT: WASD CAMERA LOOK: MOUSE



Introduction of the old article

In this article we are going to import assets, i.e. 3D models and textures, add them to the Unity engine and configure them so that they are ready to start working on stage. We are going to create GameObjects prefabricated that we can then reuse and we are going to modify the sky that comes by default, replacing it with a Skybox where we will apply the textures that were downloaded from Asset Store in the previous video.

Go to the project’s Main Page

Video related to this article

Before we begin, I invite you to watch video 2 of the series My First Game on Unity.




Import files

The first thing we are going to do is to download the necessary files for the project. You can do it in the following link.


3D Models and Textures

Within these files we will find 3D models for the labyrinth walls, a pedestal, a sword and a clock. Each model has its own textures.

Fig. 1: Display of the downloaded files.

Select the folders and drag them to the appropriate folder in Unity.

I do this first by selecting the files, then clicking to drag them (a ghost icon appears indicating the amount of files being dragged) and then pressing the ALT-TAB combination to change the window, this does not make the selection lose, that’s why we can drop the files into the Unity folder.

If there are problems to do this you can minimize the Unity window or use the Unity import options.

Fig. 2: The textures have been imported and are in the project folder.

Then we do the same with 3D models. You have to take into account the folders we created in the previous video in order to organize ourselves.

Fig. 3: The textures have been imported and are in the project folder.

Modify scenario

Now let’s put all the 3D models on the stage to start shaping the labyrinth.

First we remove all the elements of the scenario except the floor. In the previous video we had placed them all as children of an Empty GameObject called Scenario.

Fig. 4: All scenario objects are selected except the floor.

The next step is to take the 3D model called ScenarioElements that we import and drag it into the scene or hierarchy. This will place all the pieces of the labyrinth on the stage.

Fig. 5: We place the 3D Scenario Elements Model that comes in the download of this page.

In the previous video we had made the floor brown. Now we are going to apply textures so we make it white again, otherwise our texture will have a brown tint.

Fig. 6: Modify the colour of the floor material so that it turns white again.

Apply textures to the floor

Now we are going to use the textures that come inside the zip that can be downloaded at the beginning of the article.

We start with the floor, inside the folder we have three textures.

The Base Color texture is used to give color to the material. Metallic determines the behavior of the material in front of light and the normal texture also determines how the light bounces off the material, but it is used to add geometric details that appear to have a high density of polygons in 3D models.

Fig. 7: Three textures corresponding to the soil together will define the material.

Place textures in the slots of the material

We add the textures in the inspector, to see the material in the inspector we have two options: we can select the material directly from the project folder or selecting a 3D model of the world that has it assigned.

Fig. 8: Display of the parameters of a standard material in the inspector.

Figure 8 shows that the textures are assigned in the slots of the material.

Albedo slot determines the color of the material, there we place the texture Base Color. The metallic texture in the slot metallic and the normal texture in the slot Normal map. For the latter we must define that texture as a normal map, there are two ways to do this, but Unity gives us the option in the same place, as shown in Figure 8 appears a sign that says that this texture is not defined as a normal map and we have a button to fix it. We click on Fix Now.

Tiling of textures

The upper left corner of Figure 8 shows a portion of the soil. Notice that the floor looks blurry unlike what it should look like (a lawn floor with daisies).

This happens because the texture is expanded to occupy the entire plane, to change this we must make it repeat more times in the geometry. This is done with the Tiling parameter of the material, in my case (because of the size of the plane) the values 100 for X and 100 for Y work.

Fig. 9: Tiling. This will cause the textures to be distributed on a larger or smaller scale within the geometry.

What is going to happen is that the same texture is made smaller and placed one after the other. In figure 10 you can see the lawn with daisies. Notice how in the lower part of the image the ground looks good, but as we move away the pattern of the texture becomes more evident, it is obvious that it is the same texture that repeats itself.

We are using a “Seamless” texture, that is to say a texture that when you put it one after the other (in the four sides) fit perfectly and you don’t notice a line of rupture. Even though the texture is very good, we can’t avoid the repetition pattern from a distance. To avoid this we have to use more textures, place objects that interrupt the pattern and so on.

Fig. 10: The floor material has a suitable mosaic size. At a distance, the texture is repeated.

Figure 10 also shows that the floor reflects a lot of light, as if it were made of glass or something similar. To correct this we decrease the Smoothness value, making the material reflect less light.

Fig. 11: Decrease of the Smoothness parameter of the material so that it reflects less light.

Fig. 12: Final configuration of the material.

Extract materials from 3D models

In previous versions, when we imported a file with an FBX extension, the materials that could be defined automatically appeared along with the models. This has changed and I think it makes sense that we have to manually extract the materials, so we can have better control and avoid having many copies of the same material.

There are two ways to extract the material, at least in the version at the time of recording the video.

In this case we click on the imported model and in the inspector we go to the materials tab and click on: “Extract from prefab”.

Fig. 13: Extraction of materials from the imported file from the inspector.

A window appears to select the location of the extracted materials, if you want we can create a folder for the new materials.

Fig. 14: Selecting the place for saving the extracted materials.

The new materials appear in the selected folder.

Fig. 15: Display of the extracted materials in the project folder.

Apply textures to new 3D models

The next step is to do the same thing we did with the floor material, we are going to go material by material adding the textures to the respective slots.

There is a problem that arises when we have to do this type of tasks and is that when we select something in the hierarchy or folder of the project, the inspector shows us information about that selection. In our case it would be good that the inspector is blocked showing the material we are configuring.

For this there is the small padlock that you can see in the upper right corner of the inspector tab. Clicking on it blocks what the inspector shows and we can navigate freely through the project folders without losing sight of our material. Beware that this can also be a problem, sometimes we forget the locked inspector and we don’t know why we can’t see information about what we select.

Fig. 16: Placement of the textors in the materials. When you select a part from the hierarchy, its components appear in the inspector, including the material assigned to it.

Another alternative for this type of tasks is to modify the Unity layout for our benefit, that is to say to open more tabs of the project and to lock them so that each one shows a thing.

Figure 16 shows that one of my project windows shows the materials, the other shows the textures and the inspector shows the selected material. This makes the process of adding many textures to the materials faster.

Fig. 17: Taking advantage of the flexibility of Unity’s windows and the option of locking them to facilitate the process of configuring materials.

Creation of Prefabs

Once we have configured all the materials, the next step is to create the “Prefabs” that is to say GameObjects prefabricated that later we will be able to instantiate during the design or in time of execution of the game. For example, later on we will make the clocks appear randomly on the stage. In order to achieve that we need to have a GameObject prefabricated from which clones will be created.

Fig. 18: Process of creation of Prefabs. First we select a GameObject from the hierarchy.

To create a prefabricated GameObject we simply take it from the hierarchy and drag it to any folder in our project, as shown in figures 18 and 19.

Fig. 19: Process of creating a prefab. Second: we take the GameObject and drag it to some folder of the project.

After that the Prefab appears in the folder, as a thumbnail that shows its appearance and name. From there we can take it and drag it to the scene to create all the copies we need, as can be seen in figure 20.

Fig. 20: The prefab is in the project folder and can be reused.

We repeat this process for each individual piece of the labyrinth, pedestal and portals.

Fig. 21: Prefabs have been created for all imported models. In this way we can build the labyrinth and place the objects.

Define a new Skybox

Now let’s modify the standard sky of the scene. We will use the files downloaded from the Asset Store of the previous video, doing this was an optional step, so if you have the files no problem, we can keep moving forward.

First we create a new Material, we call it “Sky” and we select it to visualize its properties in the inspector.

Fig. 22: Modification of the Shader to define it as a six-sided Skybox.

Then we click on the Shader drop-down menu that by default has “Standard Shader” selected, instead we choose the Shader “6 Sided Skybox”. This will completely change the properties of the material in the inspector, now you see an inspector like the one in figure 23.

Fig. 23: Six-sided skybox type shader displayed on the inspector.

We will assign the textures of the Skybox package downloaded from the Asset Store to the corresponding Skybox slot.

Fig. 24: The textures downloaded in the previous video are assigned to the slots of the material in the inspector.

Then go to the menu Window > Lighting > Settings to open the lighting configuration.

Fig. 25: The lighting configuration window opens.

A window opens like the one shown in figure 26, which I place next to the inspector so that he is not floating.

Fig. 26: Display of the lighting configuration parameters.

Click on the icon of the circle with the “Skybox Material” point (on which the cursor is in figure 26) and in the window that appears we choose the Skybox that we have just configured (figure 27).

Fig. 27: Selection window for Skybox material. The previously created material is selected.

Immediately we see how the default heaven is replaced by a new sky of a cloudy sunset. With the appropriate images we can create a personalized sky for our project.

Fig. 28: The sky in the scene changes, now there is a cloudy sunset.

Adjust lighting

Figure 28 shows that the light is too pale, i.e. it does not look like the light you would see in a sunset. To correct this we select the light source in the hierarchy to see its properties in the inspector (an inspector similar to the one seen in figure 33 is observed).

In the inspector we select a color according to the tone of the sky and we adjust the intensity to taste.

Then we modify the rotation of the light source to match the position of the sun in the Skybox.

Fig. 29: The rotation of the directional light is modified to match the position of the sun in the Skybox.

At this point of the video I make a folder to place the prefabricated ones belonging to the stage and others for the objects. Again I emphasize the organization of the project.

Fig. 30: The prefabs are placed in folders with significant names to improve the organization.

Finally it occurs to me to add a second light source that points directly down and does not produce shadows, that way the scene does not look so dark.

Fig. 31: The color of the directional light has been changed to match the tone of the Skybox and duplicated to add light in the dark areas.

I select the light source from the hierarchy and press CTRL+D to duplicate it, then I orient it perpendicular to the ground.

Fig. 32: The new directional light is oriented perpendicular to the stage for general illumination.

In the inspector I adjust the parameters and in “Shadow Type” I select the option “No Shadows”, as it is observed in the figure 33. With this we finish the video 2 of the series My First Game in Unity.

Fig. 33: With the new directional light selected, in the inspector we make sure that it does not produce shadows.

Conclusion

In this video we have worked quite a bit on the aspect. We added 3D models and textures, so we learned a little more about the materials. In the case of imported 3D models, we must manually extract the materials that can bring or place new materials, this part is very connected with the 3D design of the piece, ie the materials defined in our 3D design software will appear in Unity, we may have the opportunity to delve deeper into this issue later.

We saw that we can create prefabricated GameObjects that are in the hierarchy. These prefabricated can be placed in the world easily, at the time of editing or at the time of running the game.

We modify the sky that comes by default in the scene, instead we create a Skybox type material in which we place textures to represent the six sides of the “sky box”, this behaves as if we were inside a giant cube whose horizon is very far away.

Finally, we improved the illumination of the scene a little, correcting the color and adding another light source that adds intensity but does not produce shadows.

Exit mobile version
Secured By miniOrange