Thiago Klafke: Environment Artist

GALLERY RESUMEARTICLES

 

CREATING MODULAR ENVIRONMENTS IN UDK

 

Introduction

This tutorial is a result of the knowledge acquired during the production of Zest Foundation. That environment started as a simple and casual study of modular sci-fi pieces and quickly grew into one of my biggest personal projects so far.

I learned a lot during the production and I thought I could repay the community with some of this knowledge.

For this environment I used 3ds max for modeling, Photoshop for texture painting and UDK for rendering. I'll try to keep all concepts pretty universal so other engines or modeling packages users can understand it.

I hope you learn a thing or two and I'm very curious to see what you make with the techniques presented in this tutorial. Send me any WIPS or final shots to mail @ thiagoklafke.com, I'll be very happy to see them!

Planning

One of the most important steps when working with modular sets is to invest a lot of time in planning. You should always export your pieces to the editor early on to put simple structures together. This is to check aspects like:

Some pieces look amazing when viewed individually but horrible when tiled. You may also get additional ideas when you actually place the pieces in the level, so never skip this step.

I always tend to work on textures first when creating modular sets. Some people prefer to model the pieces first and texture them later, but that's not the best workflow in my opinion. You will probably need to make changes later on and it gets a lot harder if you take the piece to completion without testing it first.

I always try to have at least a very simple diffuse mockup so I can unwrap my pieces as I model them. This saves a lot of time later on, specially when using geometry-space modifiers, such as Bend and FFD.

Starting your set

One of my goals with Zest Foundation was to make a large environment using a small handful of textures. This way it would be easier to keep the overall look of the environment consistent and also to save texture memory and time.

One good idea is to define a list of categories of what you will need early on. Think this step as words (units) that you will later on use to create full sentences (groups of units). The environment itself will be the book comprised of various paragraphs (areas). (I hope that makes sense)

For Zest Foundation I used only 3 categories:

  1. 4-directionally tiling wall
  2. Trim
  3. Floor

Of course I used extra textures here and there but the majority of the set was constructed with those 3 textures.

Folder Structure & Naming Conventions

Working in an organized environment is very important for an artist. This is highly personal but my folder structure for this kind of project is usually the following:

My textures are saved the following way: texturename_map. Example: wall01_d, wall01_n, etc...

Inside UDK I like to use the following structure for my Packages:

Anything else like post-process chains can go in the root folder.

Using the Grid

It's very important to keep the boundaries of the pieces inside the grid, otherwise you will get lots of tiny gaps when tiling them.

My "snap to grid" settings are very simple: Snaps to grid points only. I also like to use power of two dimensions for "Home grid spacing". This makes it easier to increment or decrement the grid steps. Example: If you start with a grid value of 8 you can decrease it to 4, 2, 1. If you start with a grid value of 5 however, you won't get rounded values anymore: 2,5, 1,25, etc... You get the idea.

Bounding Boxes & Contact Points

All pieces' bounding boxes should contain inside the 1x1 piece aspect ratio. Even if you make a 90º curved surface its bounding box should still fit on the 1x1 piece aspect ratio. A good tip is to always use cubes to check if the pieces in fact containing inside the 1x1 aspect ratio.

It's not necessary to have X, Y , Z inside the 1x1 aspect ratio. Sometimes only X and Y is fine. This is very true for the wall pieces, which were created out of planes. You are free to do whatever you can inside the plane, but it's a good idea to leave the contact points untouched:

DOWNLOAD THIS SCENE (.max & .obj inside)

The green plane represents the axis where the pivot is placed.

Some of the pieces used in Zest Foundation. The floor piece is actually 2x2. Notice how all other pieces' contact points have square dimensions.

Pivot Placement

The Pivot's placement is very important because it will define how easy will be to place your piece in the level. A general rule-of-thumb is to place it in one of the "plane" extremities. Some people prefer to place it on the center of the mesh, but I don't think that's the best approach, because it makes scaling and rotating a little harder.

Example:

Place it on the right spot and it will be a lot easier to rotate and create some interesting combinations:

Tip: When working on a set of walls try to place the pivot in the exact same position for all pieces. This makes it easier to replace units once inside the editor.

(Re)Utilizing your textures in a smart way

As I said previously, most of the units were created using the same textures. A typical wall unit in Zest Foundation was created out of 2 textures: A 4-directionally tiling texture + a trim texture. I always try to have at least one type of trim when working on textures or units: They help add visual variety and consistency to pieces. You can also do basically anything you want with a good collection of trim textures.

Here's a breakdown of some of the pieces:

Here's another example, this time from two ceiling pieces. Notice how the trim texture with the grate looks different when mapped on circular geometry:

This wall piece was entirely built using the trims collection only. Vertex colors were used to tint some parts:

The trim collection was used even on props. It might be a good idea to use unique textures for stuff like this though.

Vertex Colors

Vertex colors were used extensively to tint some parts. This worked really well with my textures since they were so clean and bright. Remember that vertex coloring work just as the "multiply" blend mode in Photoshop so if you have a dark texture or a texture with lots of color variation you won't be able to do much with vertex colors.

Vertex colors work really well in UDK but I found a little bug: They are not picked up by lightmass. I only found this out after I was finished with this environment, so if you are going to tint large areas it might be a good idea to use a colored texture instead.

One of the pieces were vertex coloring was used extensively:

Enabling vertex colors on your UDK material is pretty simple:

Other things you can do with vertex colors:

Tip: You can also the vertex colors using a separate mask. Use a LERP node inside the material editor for that.

Custom Cubemaps

Sometimes it's better to use custom generic cubemaps instead of render targets in UDK or other cubemaps sampled from the level itself. I learned that cubemaps sampled from the level work best with glass and similar materials. Metal however benefits a lot from custom cubemaps.

The custom cubemaps I made for Zest Foundation are pretty simple actually. I grabbed an screenshot of the level and modified them heavily. The main idea behind this is to add highlights to the surface instead of actual reflection information.

Here's a simple cubemap with just a few highlights:

Another cubemap using a combination of the above cubemap and an screenshot of the level:

Setting up the material in UDK is a bit tricky. First you will need to create the actual CubeMap entity. Do so by right-clicking the content browser and Create New TextureCube. Then set all the faces of the cubemap and save it.

A typical material with cubemapping enabled looks like this (the cubemap mask is saved on the Alpha channel of the "Emissive/CubeMap Mask" texture sample:

The result:

Another example. Here a simple cubemap was added very subtly to the specular map:

The result:

Using the Bend modifier the right way

The bend modifier is a very powerful tool in 3ds max but most people don't know how to use it properly. It's not precise and you will end up having to touch up the geometry a bit after use but once you learn this little trick it gets very easy to work with it.

Tip: If you are modeling units for UDK you will need a second UV channel for the lightmap coordinates. Do this before bending your geometry. The bend modifier won't destroy it..

In this example I'll make a 90º curve out of this 1x1 piece (notice the second UV map on the modifier stack):

Add an "Edit Poly" modifier and create vertical loops using connect edges. The more loops the more rounded the piece will be. Try to leave the spacing between the loops consistent on the whole mesh:

Now we are ready to start bending the geometry. I want a pretty short curve, so I added a reference cube that's half the width/length of the 1x1 piece. The extremities of this cube represent the points of contact of the final curved mesh. You can also duplicate the original mesh, rotate 90º and place it on the other extremity of the cube. Make sure the pivot point of the geometry to be curved corresponds to the "starting" point of the curve.

Add the bend modifier. For this piece I had to set the curve to the X axis and a -90 angle. The default settings don't look good though, we'll have to fine tune the bend profile:

To do that, expand the Bend modifier and choose gizmo. The gizmo position controls the bend profile. In this case I had to move it on the X axis until both extremities were close enough:

Now comes the ugly part. Go to the Top view and zoom in to get a good view of the ending point of the curve. You will notice that there's a small gap. The trick here is to move the gizmo in small increments using the transform tool at the bottom of the screen. The more you zoom in the more precise the tool gets (make sure to still have the bend gizmo selected).

After that's done, add and edit poly, select the vertexes in the end extremity and check if they are in fact on the grid. Here on this example the end vertexes coordinates are X -639,99. Type in -640 and they should lie perfectly on the grid:

DOWNLOAD THIS EXAMPLE

Other pieces built using the same technique:

Baking Tiling Textures

Most of the texture maps used in this environment were baked from simple hipoly objects. The trick is to render these to planes instead of baking to specific geometries. This way you have tiling textures and can reuse them whatever way you want.

One of the Hipoly objects (this one was "exploded" before baking to avoid AO conflicts):

I wrote a tutorial about baking these maps using xNormal, you can read it here.

Questions and Answers

Here's a collection of frequently asked questions on forums or via email. Don't hesitate to contact me if you have additional questions.

Q: This may sound dumb, but how do you combine the wall texture and trim texture onto one object. Do you have to dot twp different uv channels? A good example of this is the (Re)Utilizing your textures in a smart way part of your tutorial.

A: You need to use a multi/sub-object material. It's pretty simple. Here's a tutorial about it.

Q: Is each tile on the floor a simple plane or a beveled plane?

A: They are simple planes mostly. I added a few divisions here and there for vertex color painting though.

Q: Any chance you could add some of the project files of this scene so we can reverse engineer some of the work?

A: The tutorial covers pretty much everything I've done. If you have specific requests just let me know so I can make additions to the tutorial ;)

Q: Two questions though you talk about the one to one ratio does that simply mean just keep everything in a square box? Also how to you go about unwrapping the low poly do you A) combine everything on one sheet or do you have individual texture sheets.

A: What I meant is: Set a base size for all pieces and that will serve as reference for the entire set. If your base piece is 128x128 (1x1), then a 2x1 piece should be 256x128, but never 192x128 for example. If you keep all the entire set relative to the base piece's dimensions you won't have trouble combining them inside the editor. If you have different sizes for each piece then it will be a nightmare to work with them.

As for the low poly I use the textures outlined in the pictures: most of the pieces were built with one tiling texture + another sheet with a bunch of trim textures mashed together.

Q: If you have a sheet full of textures you have created, you then go to UVunwrap, does this mean you have to fit the UV coords to the texture, rather than the other way around (Draw on them)? 

A: Yes, that's the idea. You will probably get a little stretching here and there but nobody will notice.

The unwrapping process is pretty straight-forward: Select faces - flatten mapping/planar mapping - map them on specific parts of the trim texture.


 

The following questions were asked by Jahn Hummel for his graduation thesis:

Q: When do you recommend using modular pieces and when non-modular pieces?

A: Modular pieces work well with pretty much everything but in general you will get better results with non-organic environments, such as sci-fi and urban. But that doesn't mean you can't combine modular elements with unique modeling: When modeling a castle for example, you could models the wall uniquely (always respecting the grid of course) and use modular pieces for archways, stairsets, windows etc... It depends on the kind of results you are aiming for really. Building environments out of small sets of modular pieces is just ways to approach the thing but it's definitely not the only workflow available. A good artist knows when it's best to go for strictly modular sets and unique modeling.

Q: How do you define the size of modular pieces in an environment? Whereof do you make it dependent? 

T: You should always take into account the scale of the environment you are working on and the player scale. If you are working on small tight corridors you can use smaller pieces, but if you are working on a vast open urban environment it might be a good idea to make the pieces pretty big. A good example for this is Crysis 2: The sidewalks are small modules but the buildings' facades are big modules. This is better for performance and facilitates placement in the level.

A good starting point is: If the piece will be visible from upclose it might be a good idea to work with smaller units. If it will be used outside the playable area then it's better to work with bigger modules, merging multiple pieces in the same object.

Q: How do you approach seams between meshes? 

A: They are unavoidable on lightmap based engines but not much of a problem on dynamic-lighting based ones. To avoid seams you can do one of the following: Add an artificial seam to your piece (such as the extremity of a panel or something like that) or you can merge multiple pieces into bigger ones.

Seams aren't too much of a problem when the environment is fully textured and lit though, so you shouldn't worry about this unless they very very noticeable.

Q: Would you recommend using power-of-two units to build modular pieces when using an engine that works with a meter-based system (instead of a generic unit one)? 

A: Depending on the scale of the player model it's possible but it's definitely not a rule set in stone. If you convert power-of-two "generic units" to meters you still get pretty reasonable values: 256 units could become 2,56mts so yeah, it's possible. 

Q: Did you use a texture atlas for your textures in Zest Foundation? When do you use texture atlases?

A: I did actually, for the trims sheet. I hardly ever use texture atlases though. It's hard to plan them in advance and it's definitely harder to adjust the UVs later on if you decide to starting using them down the road.

Q: Do you create your own mip-maps? 

A: I never had to but I know you can create some cool effects editing the mip-maps. For example, if you are working on a large tiling texture for a terrain you could blurry the mip steps a little to avoid obvious texture repetition. I know they did this on Far Cry 2.

Q: What would you do differently were you to make the Zest Foundation environment again? 

A: The lighting. I'd have used the sun light better, it's barely noticeable with all the interior lights placed in the level. I found it very hard to find a balance regarding this because of how lightmapping works in UDK: Tweak a light's value a little and the result will be pretty different.

Q: How do you think modularity will be used in the making of environments in the future? Do you think it will change? Why/why not? 

A: Well, modularity has been around since the very fist videogames if you think about it. Back in the days entire games were constructed out of sets of 2D tiles with fixed proportions, so yeah, unless a new revolutionary workflow appears we will keep using modularity for a very good time.

I like to think that the 3D modules I create now are in fact an evolution of the 2D textures I used to make back in the Half-Life 1 days. The difference is, instead of working on a flat 2D plane I now have an extra axis but the idea is pretty much the same.