© Abhishek Kumar 2020
A. KumarVR Integrated Heritage Recreationhttps://doi.org/10.1007/978-1-4842-6077-7_10

10. Importing into Unreal Engine 4

Abhishek Kumar1 
(1)
Varanasi, Uttar Pradesh, India
 

In this chapter, we learn how to import the assets that we exported from Blender and Substance Painter into Unreal Engine 4.

Import Settings

Importing into UE4 is very simple. There are two ways to do it. You can drag and drop your assets into the Content Browser of UE4 or click on the Import button in the Content Browser (see Figure 10-1).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig1_HTML.jpg
Figure 10-1

Importing assets

However, before we import anything, let’s create some folders so that everything is organized. Right-click in the Content Browser to open the Create menu. There are lots of options in this menu and we will be using quite a lot of them for our project. For now, choose New Folder from the list, as shown in Figure 10-2.
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig2_HTML.jpg
Figure 10-2

Create menu in UE4

Name this folder Assets. We will keep all our imported assets in this folder. Open the Assets folder and create two more folders called Meshes and Materials. Import meshes and textures inside the respective folders. This will organize your work and prevent things from getting messy. Open the Meshes folder and click on Import to open the File Browser. Navigate to where you have been storing your exported FBX files from Blender and import one of them. A new window will open that will allow you to change the import parameters (see Figure 10-3).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig3_HTML.jpg
Figure 10-3

Import options window

You will see a ton of options that you can modify to personalize how you want your file to be imported. You need to click on the drop-down arrow under the Mesh category to expand the window and bring up a lot of new options. In this case, we are concerned with two main options (see Figure 10-4).
  • Auto Generate Collision: Every static mesh that is a solid object needs to have a collision that tells UE4 that another solid object cannot pass through it. Generating collisions is actually pretty simple. All you have to do is create a simple 3D mesh that surrounds the object. Or you can check this option and let UE4 figure out the collision by itself, which we will do this time.

  • Generate Lightmap UVs: Lightmap UVs are used for storing light and shadow data for any mesh. Since we created our own in Blender, we will uncheck this option.

../images/496700_1_En_10_Chapter/496700_1_En_10_Fig4_HTML.jpg
Figure 10-4

Modifying the import parameters

Now click on Import. This will be the setting for all the meshes that you import. If you haven’t generated Lightmap UVs for any of your meshes, you can enable the Generate Lightmap UVs option. UE4 is generally not too good at generating Lightmap UVs by itself, so it is recommended that you do it yourself. Sometimes it does a serviceable job, so try it when you want decent results with less effort.

If your asset creates unwanted material files automatically, simply Force Delete them. We will create materials on our own.

As for importing textures, UE4 does not create much fuss. Simply drag and drop your exported textures inside the Materials folder and create more subfolders to better organize everything. Textures will be imported without any parameter windows, so just ignore any warnings that appear.

Note

Always remember to save this file with the correct naming and in the right folder so it is easier to identify in later stages.

Exploring the Properties Editor

Any asset that you import has many properties that you can edit. This is done via the Properties Editor. You can access this by double-clicking on your asset. The Properties Editor window will look similar to Figure 10-5.
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig5_HTML.png
Figure 10-5

Properties Editor

Some of the important properties that we will work with include the following:
  • Material Slots: In this category (see Figure 10-6), you can assign a material (which we will create in the next chapter) to your mesh. Then, whenever you create a new instance of your mesh, this material will be applied to it as well as to every old instance that was created previously.

../images/496700_1_En_10_Chapter/496700_1_En_10_Fig6_HTML.jpg
Figure 10-6

Material slot of mesh properties

  • Build Settings: This allows you to build and rebuild various kinds of mesh-related options like recomputed tangents, to build light maps in case you don’t have them, to designate an index of a Lightmap UV, and so on (see Figure 10-7). These options will make more sense once you start working with them.

../images/496700_1_En_10_Chapter/496700_1_En_10_Fig7_HTML.jpg
Figure 10-7

Build Settings

  • General Settings: These are other mesh-related settings that you will use (see Figure 10-8). Some of them are quality and optimization related and are important to understand because, when creating a game environment, you must maintain a balance between good quality and performance optimization. Some of these settings that you should know about include:
    • Lightmap Resolution: A higher lightmap resolution will produce a higher quality shadow bake and will eliminate any artifacts or errors occurring during light bakes on the mesh. Increasing this too much will increase the load on the system and performance will decrease. In this case, you can increase it to something like 256. If problems persist then you may increase it to as high as 512 or 1024. But beyond that is not recommended.

    • Generate Mesh Distance Field: This is an important setting for open world games. This generates a proxy mesh for objects used in light-related calculations and for generating shadows. Using this will optimize your game and reduce performance impacts of large scenes with lots of large objects. This may not be useful in this case, but nonetheless you should know about it.

../images/496700_1_En_10_Chapter/496700_1_En_10_Fig8_HTML.jpg
Figure 10-8

General Settings

Build Settings in Detail

Let’s look at some build settings in detail and see how you can use them to bake Lightmap UVs.

Let’s say you are not happy with the Lightmap UVs that you have generated. Instead of going back to Blender to create them again, you can have UE4 do it for you. You can do this very easily by clicking on the Generate Lightmap UVs checkbox to activate it (see Figure 10-9).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig9_HTML.jpg
Figure 10-9

Generating Lightmap UVs

Then set the Source Lightmap Index to be the index of the UV map that you want to be the reference for the Lightmap UV that UE4 generates. The value starts at 0, with 0 being your UV map for the textures. If you want this to be your reference, then enter 0 in Source Lightmap Index field.

If you want the Lightmap UV that you created to be the source, then enter 1, because ideally that should be its index.

Finally, you need to enter a Destination Lightmap Index value, which is the UV index that will store the newly created Lightmap UVs that UE4 will generate. You can either store this in one of the UV indexes that you have in the mesh or create a new one. To see the list of available UVs on your mesh, click on the UVs tab on the toolbar (see Figure 10-10).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig10_HTML.jpg
Figure 10-10

List of available UVs

Since we have only two in this case, we enter 2 in the Destination Lightmap Index to create a new UV index and store the generated lightmaps in that. Your settings should look similar to Figure 10-11. Once you’re done, click on Apply Changes.
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig11_HTML.jpg
Figure 10-11

Generating new Lightmap UVs

Once you click on Apply, you will see a new UV in the UV tab. If you are happy with the result then continue; otherwise, you can regenerate new UVs with different settings.

Now you need to set this newly generated Lightmap UV as the one used by the engine to store light and shadow information. To do that, scroll down to General Settings. Look for the Lightmap Coordinate Index option. Enter the index of the UV that you want to use as the Lightmap UV. In this case, it should be 2 (see Figure 10-12).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig12_HTML.jpg
Figure 10-12

Setting the Lightmap coordinate index

Editing Collisions

Let’s see how we can edit the collision of our mesh. First click on the Collision tab on the toolbar (see Figure 10-13).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig13_HTML.jpg
Figure 10-13

Viewing the collision

Check each of the box individually to visualize what your collisions look like. The Simple Collision option is simply a bounding box around the shape. It does not have much detail. While the Complex Collision option is generated according to the shape of the object, and it will follow the object’s shape accurately. Simple Collision is not as performance heavy but is less accurate, while Complex Collision is obviously more accurate but will hamper performance if it’s used too much in a scene.

By default, the collision is set to Simple but if you want to change it, scroll down to the Collisions category and click on the drop-down menu next to Collision Complexity. From the list, choose Use Complex Collision as Simple (see Figure 10-14).
../images/496700_1_En_10_Chapter/496700_1_En_10_Fig14_HTML.jpg
Figure 10-14

Changing the collision type

This will make the mesh use the Complex Collision option as its default. Everything has its uses and for objects like this large wall, it is better to use the Simple Collision option. But you will want to use Complex Collision option for walls with holes or doors so that you can traverse through the gap.

That’s all for this chapter. I hope you have adequately learned how to import and set up your assets inside Unreal Engine 4. In the next chapter, you will learn about different ways to set up your materials.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.27.178