In the previous movie, we animated Sven and exported him into our Unity game level. In this movie, we’ll focus on lighting and framing our scene, as well as populating it with additional background assets. In Unity, open the file “Game.unity” from the “HSM_Game_Part4” folder, or use your own file from the previous lesson. Go to Game View. Our scene is currently lacking illumination. Switch back to Scene View, then go to GameObject>Create Other>Directional Light. The directional light illuminates the scene uniformly, similar to a light source located very far away such as the sun. Move the light above the level. This doesn’t impact its illumination, but it makes it easier to select. Rotate it to 35 degrees in the X axis and 145 degrees in the Y axis so the scene is well lit in Game View. In the Light component, set Intensity to 0.85 and Shadow Type to “Hard Shadows”. Note that while shadow casting adds depth to your objects, it can also impact your game’s performance at runtime, especially if you have multiple lights. We can mitigate this by controlling whether each object in our scene casts and receives shadows. Select the ramp section under Sven. In the Mesh Renderer component, turn off Cast Shadows since there won’t be any objects underneath this ramp to shade. However, leave Receive Shadows turned on so we can see Sven’s shadow when he hovers close to the platforms. Click Apply to propagate this change to all rampDown prefabs. Set the other section prefabs to match this change. We want Sven to cast and receive shadows, but his jetpack is so small that we can turn off these properties without much visual impact. Below the Mesh Renderer component, Unity lists all materials assigned to your current selection. Here, the materials’ shader type is set to either “Diffuse” or “Bumped Diffuse”, depending on their respective textures. While this is fine for our default type, we want to optimize all aspects of our game assets for mobile publishing, including our materials. Therefore change the shader type from “Diffuse” to “Mobile/Diffuse” and “Bumped Diffuse” to “Mobile/Bumped Specular”. Adjust the Shininess property so Sven’s armor picks up some of the incoming light and contrasts his shadows. Update the remaining materials used in the scene. You can quickly find them in the Project View by using “_mat” as the search filter. Setting these properties for each object you create is a good way to optimize your game world as you assemble it. Sadly, ours still looks pretty empty. Let’s use Maya LT to assemble some buildings to fill the background. In Maya LT, set the provided source assets folder as the current project, then open the file “buildings_source.mlt”, or import the corresponding .fbx file in a new scene. This scene contains four different buildings grouped in a similar fashion to the platforms we assembled in part 2 of this series. Modeling the buildings in a modular fashion like this allows us to quickly assemble assets of varying heights. However, some sections have a noticeably higher polygon count than others. Since the resulting buildings are designed to be background assets, we need to make them lightweight enough to minimize their memory footprint. Let’s optimize each section with the Reduce tool. Select buildingA’s “top_geo” object, then go to Mesh >Reduce [options]. Turn on “Keep original” to apply the optimization to a new mesh. This will be important later. You can set different reduction goals, such as a percentage or an actual vertex count. Use the default “50%” setting for now. We want to preserve the existing quad-faced polygons as much as possible, but we also want to maintain symmetry to keep the object’s shape… …so to accommodate both features, decrease Preserve quads to 0.95, then set Symmetry type to “Plane” and Symmetry plane to “YZ” so Maya LT mirrors the optimization length-wise. Click Reduce. Maya LT optimizes a new copy of the object, moving the original one to the side. Note that Maya LT may disconnect the copy’s material. If so, re-assign it using the right-click menu. A new “polyReduce” node connects the original mesh to the reduced copy and controls the poly reduction. If you experiment with different optimization configurations the reduced mesh updates dynamically. For example, the Sharpness attribute controls the balance of preserving small areas of details versus preserving the overall mesh shape. Set it 0.5 for now to get a balance. The Feature Preservation options let you set priorities in the reduction process, such as preserving UV borders or crease edges. To further control the reduction process, you can use the Reduce tool in conjunction with the Paint Reduce Weights tool. Note that you must reduce your mesh with “Keep Originals” enabled beforehand. Go to Mesh>Paint Reduce Weights Tool [options]. Using the Artisan toolset, set Value to 1 and click the Flood button to turn the entire object white, which means all its faces are subject to reduction. Now set the paint value to 0 and paint areas on the mesh to exclude from reduction. Maya LT updates the reduced mesh’s topology based on your blend weights. At any time, you can iteratively adjust the reduction percentage to see the compound result. You can also use the Invert weights option to swap the blend weights on your mesh. When you’re done, repeat this reduction process for the building’s remaining sections. Following the techniques we covered in part 2, use these sections to create a new single-mesh object… …and export it as an FBX file using the “Autodesk Media & Entertainment” preset, with the Animation option turned off. To help speed things along, we’ve included a “buildings_source_result.mlt” scene and corresponding .fbx file containing different variations of these optimized buildings with the provided scene files. Make sure you copy the Textures folder from your local “HSM_Game_Source” folder to your Unity project’s Assets folder. In Unity, select all your new building assets. In the Inspector, set Material Naming to “From Model’s Material”. In the Rig tab, set Animation Type to “None”. Now create a prefab for each building… …and use them to populate the background scenery. Turn on each building prefab’s Static property so Unity considers them as non-animated objects… …and change their associated materials’ Shader Type to “Mobile/Bumped Specular”. Set the camera’s position to -10, 10, and 30 in the X, Y, and Z axes, respectively. Rotate it 10 degrees in the X axis to tilt it down slightly. Go to Game View. The camera’s current field of view is too large, so set it to 30, which zooms the camera in and tightens its framing. Change the Game View’s Aspect drop-down to “16:9” to get a widescreen preview. Lastly, let’s replace the empty background with something a little more colorful. This background texture represents the initial concept art used to showcase our game. We’ll use it as a placeholder texture for now and eventually swap it with a more polished version in a later movie. Go to GameObject> Create Other>Plane. Rename it “background”. Rotate it 90 degrees in the X axis and move it to -85 units in the Z axis. Because this plane only acts as background and does not interact with the rest of our scene, we don’t need to keep its Mesh Collider component. Right-click it and select “Remove Component”. Also, turn off both Cast Shadows and Receive Shadows properties. Go to Assets>Create>Material. Rename it “background_mat”. Drag this new material onto the plane and set its shader type to “Mobile/Diffuse”. Click the Select button and choose the background texture. To ensure the plane respects the texture’s proportions, set its scale to 20.48 units in the X axis and 5.12 units in the Z axis, which represents its resolution divided by a hundred. However, even at that scale, the background plane doesn’t cover the entire level. Fortunately, this texture can be tiled seamlessly, so what we can do is set the material’s “Tiling X” property to 3 to repeat the texture three times… …and triple the plane’s scale in the X axis to 61.44 units. From here, adjust the plane’s scale until it completely fills the background in the Game view. In the next movie, we’ll script Sven’s hovering controls and introduce obstacles in his path.