The 3D and Windows 8 : Unity 3D 4


For several weeks, rumors were increasing. We were surrounded by news about a 3D engine available for the big day, the launch of Windows 8). And, you probably know that 3D, well, it’s my great passion. So did I wait for my fellow workers who did not take their summer break, to come back from Amsterdam in this late August, to get my hands on the USB key gathering all that is necessary to install this first-class tool. Let’s have a look !


The present article is done with the beta version of Unity 4. Not a big deal there, all is running perfectly fine. The only trick is to install the previous version of Unity, and then to install the new one as an update. Nothing too serious, when you think that this version is still labelled “beta”. The installation runs smoothly and is right in the common standards of x86 or x64 installers. Of course, you will surely need a good and robust DirectX 11 “gamer” PC, or a dedicated workstation to feel comfortable while producing your 3d worlds. However, you will need an additional 3D software (3ds Max or Maya) to get all of your 3D assets quickly and properly done.

First encounter: the UI.

That interface is a bit confusing, on the first shot, because you do not land in a classic “4 viewports” layout. In fact, the tools are laid in menus in the upper part of the UI, then comes the single 3D view of the 3D scene, with its controls, then, just below, the scenegraph tree view, gathering all the items of your virtual world, and finally, on the right side, the properties of the selected element. Please note at this point that this UI is deeply dependent of additional scripts. These scripts can be loaded within the project at any time, changing the way the properties of the selected item are displayed, and changing their capabilities. We will come back to that point later on.

Did you notice that “Play” button, in the upper part of the UI? This will become handy when testing your scene. After triggering that button, you will toggle into the 3D world in test mode, just as you will do in the game engine itself, without compiling.

Speaking about the UI, and specifically about controlling the 3D viewport, of course you can use the icons just below the menus, but you can also use the mouse context: maintain right-click to rotate, middle click to pan, and mouse wheel to zoom in/out. This is the place where you can move and scale your assets.

Be also aware that the default unit system of Unity is the meter.

Create the terrain

The terrain creation, to support your “playground” is the first step in the discovery of Unity 3D. That terrain can be defined by mathematics or by a texture, named a height map. But before creating from scratch the elevations, you need to carefully set up the terrain. First, add a terrain in the scene (Menu bar-> Terrain-> Create Terrain). This should create a nice and flat plane in the middle of the system, near the origin point (the 0,0,0 point…). But, for the purpose of that article, this Terrain is far too large. We will tweak that a little: Get back to the Terrain menu and choose Set resolution. A panel opens up, allowing to configure more precisely the terrain asset. In our case, we do not need a 2kms per 2 kms playground. Tweak the terrain Width and terrain Length values to 512 and simply click on Set resolution

Then, we will model the terrain with a texture. Open your favorite picture editor and create a 512×512 pixels image. Paint your levels to obtain a chaotic and noisy picture. Imagine that the black pixels are for low altitude points, and white pixels are translated as high altitude points. Of course, all the shades of grey in between are there to shape the slopes. The output format of your file will be the .raw format, in greyscale only (no RGB there).

Once this texture is saved in the proper format, go back to Unity, in the Terrain menu and choose Import Heightmap. In this window, aim to your raw file and set the value of the height parameter on the Y axis to 30. Click on the import button. Waoo, do you see that? A nice and realistic terrain! A bit grey, certainly, but no doubt we’re going to fix that. Ok, I think it’s time to save your file.


Typical heigtmap


Modeling the terrain

Mapping the map…

It’s now the time to create a texture for our playground. And to do that, we will need extra tools. And these tools can be found there as scripts for Unity: Go to that address and download the Terrain Assets pack. Unzip it and place the TerrainToolkit in the local directory of your project.

Turn back to Unity, go to the Assets menu, choose Imort Package->Custom Package, aim to the Terrain toolkit and import. In the Project treeview, the Terrain toolkit should be open and its components should appear. Drag and Drop the Terrain Toolkit component (not the folder) onto the terrain, in the 3D view. Magic! The Inspector opens (on the right side of the window), full of new opportunities: Create, Erode and Texture> Click on the Texture button, then Add Texture, and in the texture slot, click Select to define the cliff texture. Obviously, you can select the pretty well named Cliff texture). Repeat the same operation for the lowland (this time use the grass texture) and tweak the slider right above to get the right balance between the cliff start and the cliff end values. Don’t forget to click on the big black Apply procedural texture button to validate the changes.

Eventually, if you’re some kind of adventurer, you can add some more layers to simulate the snow, just by repeating the same process. And do not forget to save your file!


Texturing the terrain

Let there be light!

In this chapter, we will add a light source to our scene. That process is quick because we only need one light to simulate the Sun. To create the light, go to the GameObject menu -> Create Other -> Directional Light. Once the light is created, move it to the right location, and do not hesitate to take it far from the terrain. As a directional light, the distance does not affect the intensity nor the definition of the lightning.

Of course, take time to have a look to the Inspector panel to set up the intensity, or the shadows type of the light source. (Be aware that real time shadowing requires the Pro version).

The Player and the respawn point

Ow, I think it is the right time to begin a little test procedure and to have a first look to our 3D scene. And to get prepared to this, you have to create a respawn point, for the player’s camera to be located initially. Once again, we will have to find the right script to enhance the capabilities of Unity. Open the Assets Menu -> Import Package-> Character Controller. It should load the controller. Then drag&drop it in the 3D view, from the Project thumb, Assets, first Person Controller.

Move the controller in the 3D view and choose carefully the Y axis location (your payer should not be too high above the ground, or it will fall in the 3D scene during initialization of the game mode). Once the player respawn point carefully set up, you can switch to the “Game Mode” (just above the scene viewport), click on the Play button, and feel how the engine reacts to your scene. Use the mouse to change your point of view and the keyboard arrows keys to move forward, backward, to the right or to the left.

Click once more on the Play button to fall back in the Editing mode and… yes…, save your file.

The environment

How good is a 3D scene without a nice environment? For instance, in this chapter, our mission is to add a nice sky to the mockup. How? First, load a new skybox asset tools (Assets-> Import Package-> Skyboxes). Then, in the Hierarchy panel, expand the First Person Controller and select Main Camera, in order to make its properties appear in the Inspector tool. Make all your way down that panel, click on the Add Component button, an choose Rendering->Skybox to add the skybox mode to the camera assigned to the player’s controller. Drag & drop from your assets list a skybox (not the texture, choose the component) directly in the skybox zone, in the Inspector panel of the Main Camera (for example, Sunny! skybox).

Speaking about environment, we will now add a nice fog to our scene to increase the feeling of depth. Open the Edit Menu-> Render Settings. In the Inspector, check the box labeled Fog. Choose a nice dense blue and you will obtain a nice depth fog. Things are getting serious, here!

Last step, tweak up the ambient value in the same panel to correct the unlit sides of the objects, You can save.


Sky and Depth Fog

Adding foliage.

Our 3D world, for now, is a bit empty, don’t you think? Select the Terrain, and go back to the inspector window. In the Terrain (script)

thumb, you should see a set of buttons to raise or lower the terrain, and one specifically laid there to make you feel like a gardener.: Click on the tree button, choose a specific tree (and if it comes that you do not find the desired tree, you can alternatively load a specific package, like Tree creator, for instance) , select a brush (size and density) and start scattering trees all over your terrain, just by painting it. Now, here is a little trick: If you hold the Shift key down while painting, you will erase the trees under the brush … Also notice that you can scatter grass, just the same way. And if you play with the assets, you will soon be able to add parametric a wind zone, which will animate your trees…


A nice natural spot…

Importing FBX objects

For all non-procedural 3d object, you will need to work with an additional 3D editor (3ds Max, Maya, …). These programs often allows to export the meshes in FBX format. This is the proper format to grab the meshes and 3d assets back into Unity 3D. Pay attention to the units, and don’t forget to embed the texture prior to export (embed media). I all is done correctly, you should import with no problem. To do that , open the Assets menu -> Import New Assets and aim to the .FBX file. Then, move the 3d objects to their correct position, using the translation, the scaling or the rotation tools, located just below the menu bar. And if, once again, you add a specific physical component, you will make that object “colidable” (the camera cannot pass through the object).

Test and compilation.

Last but not least, you can compile the 3D scene as a stand-alone exe. In this process, all the resources, assets and scripts are gathered in one single executable. To do that, go to the File menu->Build Settings and set up properly the compilation process. First, click on Add Current, to add your actual project to the “to-do” list. Then choose the type of project you want to have a look to. For our test, select PC and Mac Standalone and Windows 64-bit (or 32-bit, depending your hardware capabilities). Specify a path to generate the executable, then click on Build And Run and…. Tadaaa, you can run in your 3D world (after just a smart launch panel).

Please note here that you can generate a modern UI for Windows 8 with Unity, but, as I’m writing down this article (unity is in Beta mode…), it’s quite difficult to obtain a first-shot exe compilation. By the way, you will sonly be able to specify all the required assets, such as the splashscreen, or the tile bitmap, and create your own certificate in order to deploy the 3d scene or your local dev machine.


Final scene with particles and baked shadows…easy!

Final words

As you may have yet understood, Unity 3D 4 is an emphatic tool, because of its simplicity, its usability, its “user-friendly” approach, and its capabilities. The learning time required to master all of its basic functions is very short, if you’re used of making real time 3D mockups. The overall philosophy of the product is convincing and elegant, especially the script/plugins. That part will bring your scenes to an unprecedented and specific high level, as long as your team do have a developer. Hopefully, the technological value of Unity keeps inflating, with the native compiling for Windows 8 Modern UI environments, which makes this new version a fantastic, modern and inline companion. A very good release, with nice promises!

Comments (0)

Skip to main content