From Textures To Materials in Unreal Engine 3, Part 3

This is part three of the tutorial “From Textures To Materials In Unreal Engine 3″, in which we will create a new material in UT3 which uses textures we’ve created from scratch in Photoshop. The third and final part of this tutorial concetrates on Unreal Engine: importing, assembling and using.

Note to reader: This tutorial uses Unreal Tournament 3, Photoshop and xNormal to generate normal maps. The workflow might very similar in other Unreal Engine 3 games, and you can do the same things in GIMP or another equivalent that you can do in Photoshop. You can download xNormal for free, or use other software (such as CrazyBump) you’re familiar with. Within this post, UE3 means Unreal Engine 3, PS mean Photoshop, UT3 means Unreal Tournament 3 and UT3Ed means Unreal Tournament 3 Editor. I expect you to know the basic functions of UT3Ed and Photoshop. If not, you can Google for tutorials on both.

If you haven’t already, go and see part one and part two of this tutorial. If you’ve read them already, please continue wth part three.

Working With The Unreal Engine

The Unreal Engine has always supported map-specific packages to hold assets such as textures and meshes. In this part of this tutorial we will create dummy level for our material before importing anything. This will create the map package for us to import our textures in. It is advisable for normal Unreal Tournament 3 levels to use the map’s own package to store custom assets used in the map. Mod teams and larger groups on the other hand need to create larger independent packages for various reasons.

Open up the editor and create a new level with just a single room. No need to decorate unless you want to. Take your time.

Then save it, I’m calling mine “DM-TEST-FloorTile_Stone_Material.ut3″. When you saved your level, the engine created the map’s package in the generic browser, where you can now import your own assets.

Importing To Unreal Editor

Open the generic browser of the editor. On the left asset filter list, tick “material” and “texture”. Now we will only see materials and textures in the browser. Our map’s own package isn’t visible yet because we do not have any assets in it yet. Let’s change that.

Open “file” and select “import”. A file browser window opens up. Browse to your diffuse texture you created in part two and open it. A window pops up:

fig 1, the unreal editor import window

Figure 1: The Unreal Editor import window. Proper options for this texture are also visible. Click for larger version.

From the package menu, select the name of the level to save this texture into it’s package. Give it a group if you want to, I added “Floors”. Changing the texture name is also optional, I kept it as is. Remember to tick non-alpha compression as we do not have any. After you’re done, click OK.

Look for your map’s package in the sidebar now, visible isn’t it? Open it and view what you just imported. The diffuse texture with red borders around it should be sitting in there.

Time to import the specular. Select import again and search your specular map. Wait for the import dialog. Make sure the package is right and name to your linking. Check non-alpha compression, and in LODGroup, select WorldSpecular, as this is a specular map. Hit OK. Now there should be a specular map and a diffuse map in your map’s package.

Let’s continue: the normal map. Import again and wait for the import window. Check the package and the name. Now tick non-alpha compression, use WorldNormalMap for LODGroup and look at the compression settings: select TC_Normalmap. Hit OK to import.

Next up: the height map. Import again and let’s see if there are any options to change in the import window. Nothing interesting, check names, tick non-alpha and compress as TC_Grayscale. Click OK. Now we’re done importing our texture files. Don’t worry if the preview images look quite different than in Photoshop, they will work as they looked back then.

fig 2, all the necessary files are now imported, and ready to be assembled

Figure 2: All the necessary files are now imported, and ready to be assembled.

Creating The Material

This is it folks, time to assemble! With the four textures we imported, we can create a fully functional and somewhat good looking material to be used in UT3 levels.

Click file and select new. Browse to the proper package and give the material a name. I named mine “MAT_FloorTiles_Stone”. Set the factory to “material”. Hit OK. If the editor prompts you to fully load the map’s package, do that. A new image with a green border should appear besides you red bordered textures.

Now we’ve got a so called “empty material”, which displays the default checkerboard of UE3. We need to add textures and expressions in it to make it look like something cool. Open the material editor by right-clicking or double-clicking.

A window comes up. This is called the Material Editor. In this editor you can create all sorts of materials. I’ll be teaching you the basics, which are needed to make this material using our textures.

On the left is the preview viewport, and above it are all sorts of buttons. The geometric shapes resemble the shape you want to see the material on in the preview viewport, and you can toggle grids, use meshes in the preview, et cetera. They’re quite self-explanatory if you hover your cursor over them.

The big gray area is what I call the “node window“, this is where the magic happens. You add texture samples, expressions, connect dots and make things look good. Right clicking will bring up the same menu as the right sidebar is: the expression list. Clicking on one will add it to the node window.

On the bottom are the properties for either the material itself, or the currently selected expression. Here you can insert properties for different things, assuming the selected expression has any.

fig 3, the material editor window

Figure 3: The Material Editor window. Click for larger version.

That was the quick tour through the material editor, now we can get to a game called connect the dots. This is done in the node window by adding things and connecting them in a correct order.

Firstly, add a TextureSample expression to the node window. These expressions are used to bring textures for use by materials. Look at its properties. There is an empty texture parameter. Browse (using the magnifier near the right end) for your diffuse map and insert there. The expression should now show your diffuse map in the node window.

Try connecting it’s black RGB connector to the material’s diffuse connector. What happened? That’s right, your diffuse is now diffusing the material, and became visible in the preview. Look around in the preview window to see from angles.

Add another TextureSample, and use your specular map with it. Connect to specular and see if there are any changes in the preview. If you slowly move around the preview mesh, you should spot something shinig on the surface of the tiles. That’s specular! But it’s awfully brown to be honest. Let’s tone down the color a bit. Right click on the node window, and look for a Desaturation expression. Add it. Now connect the specular map to the desaturation expression and then connect the desaturation to the specular connector of the material. See the difference? No colors. At all. We wanted some color, not none.

No worries, we’ll plug a Constant to the percent connector of the desaturation expression to control the amount of desaturation. Add the Constant, and in the properties change its value to 0.5. Then connect it to the percent connector. The values accepted by this connector range from 0.0 to 1.0. Let’s view the material so far:

fig 3, the material editor window, with diffuse and specular connected

Figure 4: The Material Editor window, with diffuse and specular maps connected. Click for larger version.

Looks okay, but still a but Qukae 1-ish to be honest. Next we will add detail our normal map, and a close detail additive normal map if need be.

Add another TextureSample, browse for our normal map and connect it to the normal map connector. See the difference? Lighting! Normal maps do give a huge boost to the believability of the material. Although we could pump it up some more. Remember when in the first part I told about toning down the blue channel to bring out the details some more. Let’s do that.

Next to the normal map texture, add a Multiply expression and a Constant3Vector expression. Multiply multiplies two inputs together and with Constant3Vectors you can create solid colors with red, greed and blue values. Connect the normal map texture and the constant to the multiply. Give the constant a value of 1,1,1 to create a solid white. Now connect the multiply expression to the normal map connector of the material. It isthe same as before yes, because we multiplied with one, meaning there is no change.

Now insert a value of 0.5 to the blue slot in the Constant3Vector. See the change? The normal map now really pops out of the material.

Let’s try adding a detail normal map. This is to add detail when the material is viewed from a close distance. Open your generic browser, and seach for a package called “UN_DetailTex” in the left sidebar list. Right-click and select “fully load” to see all its contents. I’d suggest trying “UN_DetailTex_Crackle3_N” for our detail normal. Add it to our floor material, besides the old normal map texture.

It needs to be scaled down, or it will become a large detail normal map. We need small details now. Add a TextureCoordinate expression behind it and connect it to the UVs connecter of the detail normal map. In TexCoord’s properties, type in 8 and 8. That should be small enough. Now we need to add it to our old normal map texture, before connecting to the material connector. Insert an Add expression. Connect the texture sample and the multiply to it. The normals washed out a little, didn’t they? To fix this, multiply the new detail normal map with a Constant3Vector too! Try a very, very low value for the blue channel, such as 0.1. It worked for me. I then added the multiplied texture samples together and connected to the normal map connector, like this:

fig 5, the material editor window, with normal maps connected

Figure 5: The Material Editor window, with normal maps connected. Click for larger version.

Okay, normal maps are done, now we’re going to add some parallax mapping with our height map.

Add a texture sample using it, and take a bit further back than the TexCoord expression is. Before it, create a BumpOffset expression. Connect the height map’s red, or green or blue channel to it’s height connector. Add another BumpOffset, nearer to the TexCoord expression, as we’ll draw the coordinate input from it to this BumpOffset. Connect the height map to this expression too, and then connect the TexCoord to its coordinate connector.

Now the magic happens: connect the first BumpOffset to the UVs connectors of each texture sample, except the small detail normal map. Then connect the coordinated BumpOffset to the small detail normal map. Take a view on the preview. nothing too dandy, something visible, but only a little.

Now open the properties of both BumpOffset expressions, and change the HeightRatio from 0.035 to 0.075. The larger the number, the more it bumps. You can also play around the ReferencePlane slot. I set mine to 0.25. The lower the number, the higher the offset seems to appear. Don’t panic when some expressions turn pink, it is normal behaviour.

Here’s the material setup so far:

fig 6, the material editor window, full setup in view

Figure 6: The Material Editor window, full setup in view. Click for larger version.

We’re almost done in the Material Editor, only things we need to change are the properties of the material itself. Most importantly the physical material and a fallback material. To create a fall back material easily and painlessly, just click on the middle green checkmark on the top menu of the material editor. This creates a fallback material to the same package, next to your ordinary one. Fallback materials are used for older graphics cards, which cannot sometimes run along the engine and have to reduce the amount of data turned in by materials, or when their technology is too old to display certain features of the material.

In the generic browser find this fall back material (usually suffixed as “_fallback”) and assign it to the fallback material slot of the proper material, unless it already is.

Physical materials tell the material what physical properties it has. This affects things like shooting at the material and moving on it. To assign a physical material, you need to find one and assign it to the materials PhysMaterial slot. Remember to tick the correct checkbox in the asset filter area of the generic browser. There are physical materials over at the package called “PhysicalMaterials” (tada!). I chose stone, but you can choose any which you wish.

Remember the save the material when prompted, or by clicking the leftmost green checkmark on the toolbar. Our work within the material eidotr is done. Congratulations, you’ve just created a working material!

Using Your Brand New Spanking Material In UT3 Levels

Using your new material is like using any other retail material. Select from browser and apply to surface, mesh, or anything. I made a small test using my material and got this:

fig 7, my test with the new material, utilising a room with different lights

Figure 7: My test with the new material, utilising a room with different lights. Click for larger version.

What Now?

I glad you managed through that typohell all the way here. I hope you learned even something about the material system whch UE3 uses and what is needed to create a material.

Feedback can be left here with comments, or through means found at the about page. I can bet my ass this tutorial is riddled with mistakes and typos, so any pointers will be greatly appreciated. Thanks.

Comments

  1. Pete commented on 15/04/2009 at 00:09:

    Great tutorial! It was quick, dirty, straight to the point without unnecessarily detailed explanations. Appreciate it.

  2. Otto Rask commented on 16/04/2009 at 09:55:

    No problem! Glad to be of assistance. :)

  3. Jon commented on 02/11/2009 at 13:01:

    Thanks for that little explanation. The Normal map treatment was what I needed. I’ve been tinkering with Unreal with week, and i’ve just been plugging my normal map straight into the normal slot without doing anything else… It barely looks like it’s on there. i’ll try this when I get home from work

  4. Otto Rask commented on 05/11/2009 at 13:43:

    Great to hear this was useful to you!

    I had the same problem as you, but after just asking on forums someone told me how to get more pop in the normal maps. My materials have not been the same after finding out how it worked.

  5. Chris commented on 15/11/2009 at 22:57:

    Well done. I didnt get exactly the same outcome when making the fiber texture (photoshop Cs4) and my settings were a bit different to get the dark creases in between the tiles, but I learned a lot. thanks again

  6. Freddie commented on 17/11/2009 at 11:53:

    Cheers for this man, learnt alot. Great Tutorial. now just gotta recommend to my friends :)

  7. Otto Rask commented on 21/11/2009 at 19:32:

    Chris: Yeah, this was originally made with an older Photoshop version, and if I recall, some of the options and filters are different from those times. Thanks for reading! :)

    Freddie: Great to hear and many thanks! :)

  8. Philipp commented on 23/11/2009 at 07:56:

    Thanks a lot for these tips! I will try out xNormal.

  9. Otto Rask commented on 23/11/2009 at 09:11:

    Philipp: Yeah, I’ve found xNormal quite good enough for the general needs of a hobbyist. :)

    Thanks for commenting!

  10. Matt commented on 29/12/2009 at 01:25:

    Thanks for the tutorial, it helped reinforce some stuff I’ve already learned and also clarified normal map generation! I’ll use some of these tricks in the future (preparing for a career in level design) :)

  11. Otto Rask commented on 03/01/2010 at 14:54:

    Matt: No problem and good luck on your goal of becoming a level designer! :)

  12. Keni commented on 13/02/2010 at 00:41:

    Great tutorial! Obviously it took you quite some time to do, appreciate it!

    I’ve been messing around with UDK for 1 week and a couple of days, combining it with Blender (or at least trying to, because it seems there’s not much support for it right now and that .ase exporter doesn’t seem to be working properly all the time, anyway…as you can see I am still quite a newbie in the whole game creation process thing, so I was wondering if you could help me with some issues, concerning texturing I’ve been struggling with?

    I made a model in Blender and used UV Smart Projection then exported the layout as a .bmp file and painted it in Paint.NET, after that I loaded it back into Blender, applied a new material to the model, chose the texture type to be an image, allocated it ‘comes from the UV’ (not sure how to explain this as I’ve been messing around with so many tutorials and stuff and got pretty confused to be honest), ticked the ‘Alpha channel’ (whatever that means, I only did it because I saw it in a tutorial) and I had my texture properly applied everywhere on the model when rendered in Blender.

    Next step I did was I exported the model by using the .ase exporter script thing for Blender that makes it compatible with the UDK. (about this, I was wondering is the model actually being exported with the texture itself during this operation or not?)

    After that I opened UDK, imported my model (some error pops-up every time, saying vertex count limit exceeded or something like that, which I have no clue what it means, since my model is only ~660 vertices, I checked it inside Blender itself, is that actually that much? And I think it’s because of that, when imported, in thumbnail view, in the Content Browser my model won’t have a preview icon, it’s just black, any idea how to fix this whole issue?) Next thing, I imported the already painted UV layout I used for applying the material in Blender as a .bmp texture file and went to create new material. I added a Texture Sample and connected the black node with the defuse I think it was the first one on the left and saved the material.

    When I drag-drop applied it to my model in the UDK editor it looked fine (or at least I think so), so I was wondering, most of all, why am I going through a completely different process of work, comparing to yours? I already read the whole tutorial and I really got confused by how many ‘textures’ actually have to be created in order to have a proper material in UDK, but then again how does mine worked with the UV layout thing only?

    I am aware that this has got really long, but I’d be really glad if you could explain these issues I’ve been having!

    Cheers mate!
    Keni

  13. Otto Rask commented on 13/02/2010 at 15:32:

    Well we are creating these materials for different purposes. Mine is a simple tiling material for BSP surfaces for instance. Your model has UV maps, which then again needs a different way of laying out your texture (no tiling for instance). But in its basic level, your UV mapped model’s material will get all the components which my material in this tutorial has (diffuse, specular, normal and so on). You will just have the textures applied on a model with an UV map. :)

    I’m certain you should not tick ‘alpha channel’ if your texture doesn’t use one (RGBA).

    You can change the icon of your mesh in the Unreal editor inside the static mesh editor (’save mesh thumbnail’ or a similar icon on the toolbar).

    I’m not familiar with Blender, so I can’t say anything about the problems you’re experiencing with it.

    If I remember correctly the maximum triangle count on a mesh you can import to Unreal Engine is over 50000, so you should be just fine with a model having 600 vertices. Not sure at all why UDK would throw such an error. Have you viewed the full scene stats (or similar) in Blender to see if something “hidden” is exported with the actual mesh?

    Thanks for commenting and no problem! Glad to see an extensive question amongst the comments. If something bogs your mind too much, feel free to comment again. (I’m in a bit of a hurry to I quickly got something written to be of aid.) :)

  14. Keni commented on 13/02/2010 at 22:33:

    Hey mate,

    Thanks for the quick reply! NOW it’s really got clearer to me! :)
    I’ll check the thumbnail thing in UDK, see if it works.

    As far as the poly count, searched the forums thoroughly and found out I can just ignore that error message. There is a ‘fix’ somewhere obviously, but I won’t bother, since this is due to the ase exporter…

    Anyway, hope you didn’t mind my asking, I may be back for some tip or advice, if it’s fine by you of course! But, thanks again! Will do some work soon and will probably leave some feedback again…hopefully with some visual materials this time ;)

    Cheers!
    Keni

  15. Matthew Barcas commented on 28/06/2010 at 01:03:

    Thanks for the tutorial! I’ve just started to work with materials and I must say it is quite complex, but seeing your tutorial cleared up a few things. I have a request that is quite large, and I was hoping you could help:

    I was wondering if you could make a water shader tutorial. I’ve been searching around the net and all I could find is Hourences water tutorial, but he doesn’t explain how to make the textures and it’s very very hard to understand without already knowing a lot…I also tried understanding the math concepts behind the example water shaders included in UDK and to be honest it’s still not processing.

    If you could respond with a yes or no that would be great! Thanks again for your time :]

  16. Otto Rask commented on 28/06/2010 at 13:40:

    Matthew: No problem and many thanks for reading!

    I could try my hand in creating a tutorial water material of my own (a well commented and documented one that is). Currently I’m in army, but within two weeks my service ends and I could maybe manage a new tutorial. We’ll see then, hopefully I’ll have some time in the evenings to craft something. :)

    I’d say a simple “one-for-all” shader could be good for starters. Perhaps a more elaborate and detailed water/liquid material later on.

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>