Monday 26 June 2017

Texturing

Step 1 What is Texturing?

In 3d graphics, texturing means the process of creating and applying textures to the model. In fact, the term texturing consist of two things: UVW mapping and texture painting. UVW mapping was covered in my previous tutorial and this one will concentrate on the texture painting. We’re going to create the texture by using Photoshop and Viewport Canvas. Viewport Canvas is a 3D paint inside of 3ds Max. In the picture below you see the result of this tutorial.
Monster textured in 3ds Max 2011

Step 2 Mental Ray Renderer

We’re going to render the scene with Mental Ray. By default 3ds Max uses Scanline renderer so we have to change that. Change the renderer to Mental Ray ( Rendering > Render Setup… > Common tab > Assign Renderer > Production > mental ray Renderer ).

Step 3 Prepare the Model for Texturing

We continue from the unwrapping tutorial. As a starting point we should have the unwrapped model with the Turbosmooth modifier applied. We don’t need the checker material anymore so let’s get rid of that:
  1. Open Material Editor ( Press ‘m’ in keyboard ).
  2. Select a new (empty) material slot.
  3. Click “Get Material” button and select ( doubleclick ) ‘Arch & Design (mi)’ from the list ( Materials > mental ray > Arch & Design ).
  4. Assign the new material to the monster ( drag and drop ).
3D model in 3ds Max

Step 4 Texturing with Viewport Canvas

Viewport Canvas is a new feature in 3ds Max. I think it was introduced in 3ds Max 2010 and in 2011 it has been completely upgraded. If you don’t have 3ds Max 2011 you unfortunately can’t really follow this tutorial. If you have Photoshop, you could render a UVW template ( Unwrap UVW > Parameters > Edit… > Tools > Render UVW Template… ) and try to apply the ideas on top of that. Anyway, let’s launch Viewport Canvas and start painting.
  1. Select the monster model.
  2. Open Viewport Canvas ( Tools > Viewport Canvas… ).
  3. Click on the ‘Paint’ tool ( to activate the paint mode ).
  4. Select ‘Diffuse Color Map: …’ from the menu ( Viewport Canvas needs to know which map channel we’re painting.). A new dialog appears.
  5. Set the size of the texture map to 2000×2000.
  6. Select the folder for your file, name your file, and select PNG as file format ( I recommend choosing RGB 24 bit as color depth. Alpha channel is not needed. ).
  7. Click ‘OK’ to save the file.
Texturing with Viewport Canvas

Step 5 Starting Texture Painting

Let’s use the Fill and Gradient tools to give some color to our monster:
  1. Go to the front viewport.
  2. Select green color ( R103 G132 B58 ).
  3. Active the Fill tool and click on top of your monster.
  4. Open the Layers dialog ( Layers work just like in Photoshop ).
  5. Create and activate a new layer.
  6. Select dark green color (R44 G56 B24).
  7. Activate the Gradient tool. Click and hold on the bottom of the monster, drag upwards, and release when you’re satisfied with the gradient.
Texture painting in Viewport Canvas

Step 6 Saving the Texture

Deactivate the Gradient tool ( or whatever paint tool you have currently activated ). A new dialog appears. At the moment there are two layers but layers cannot be saved in a PNG file so something has to be done. There are several options and they are all pretty self-explanatory. We select ‘Save as PSD and replace texture in material’. I think that’s usually the most preferred choice. Now the file is saved as PSD and applied to the diffuse color channel in the material. You might wonder why we didn’t save the file as PSD in the first place. Unfortunately 3ds Max doesn’t allow that at the moment but I’m guessing it will change soon.

Step 7 Working with Photoshop

Next we’re going to work with Photoshop to create some texture:
  1. Open this file in Photoshop
  2. Desaturate the image ( Image > Adjustments > Desaturate )
  3. Apply ‘Palette Knife’ filter ( Filter > Artistic > Palette Knife… ). I used values ( 15, 3, 0 ). The idea is to have a painted look to the texture.
  4. The image size should be the same as our texture size in 3ds Max. Adjust if necessary.
  5. Save the file and return to 3ds Max.

Step 8 Apply the Texture to the Model

Let’s apply the texture to our model. You could do it in Photoshop but I’m using Viewport Canvas:
  1. Select the monster model.
  2. Open Viewport Canvas ( Tools > Viewport Canvas… ).
  3. Activate any paint tool ( to activate the paint mode ) and Open the ‘Layers Dialog’.
  4. Create and select a new layer
  5. Apply the texture we just created to the new layer ( In the Layers Dialog: File >Load Bitmap Into Current Layer… )
  6. Change the blending mode of the new layer to Overlay
  7. Change the opacity of the new layer to 35%
Viewport Canvas workflow
Tip: If the texture is displayed in low resolution go to the display driver settings and and maximize the resolution ( Customize > Preferences… > Viewports > Configure Driver… > Appearance Preferences > Download Texture Size > Match Bitmap Size as Closely as Possible ).

Step 9 Removing Texture Seams

Now the monster has a nice painted look but unfortunately the texture seams are clearly visible. Next we’re going to do something that would be really difficult in Photoshop but really easy in 3d paint. We’re going to use the Clone tool to paint over the seams:
  1. Activate the Clone tool.
  2. Orbit around the model to get a good view of a seam.
  3. Select suitable brush radius ( I recommend using a pretty large brush ). Tip: The shortcut to brush radius is CTRL + SHIFT + Left click & drag.
  4. Set the sampling point by positioning the pointer to suitable area on the monster and ALT-clicking.
  5. Paint over the seam.
  6. Use this method to remove all the seams. You must set the sampling point again several times until you are done. Convincing cloning takes usually some time. Experiment with the hardness of the brush as well.
Cloning seams

Step 10 Creating Details

Let’s create more details by adding another texture to our layer stack ( just like in step 6 ):
  1. Load this file.
  2. Create and select a new layer ( Make sure the new layer is the topmost layer. You can change their order by dragging and dropping ).
  3. Apply the texture to the new layer ( In the Layers Dialog: File >Load Bitmap Into Current Layer… )
  4. Clone the seams away
  5. Change the blending mode of the new layer to Overlay
  6. Change the opacity of the new layer to 30%
Now we have more small details in our texture. As you see this is very fast method of adding some random details to the surface. Now our diffuse map is complete. Next we’re going to create and apply texture maps to bump and reflection channels as well.

Step 11 Applying Reflection Color Map

Let’s apply a reflection color map to the material:
  1. In Viewport Canvas, deactivate any paint tool you might have active ( this is done to deactivate the paint mode).
  2. In Viewport Canvas, go to the ‘Options’ rollout and change ‘Paint On:’ from Diffuse Color Map to Reflection Color Map. A new dialog appears.
  3. Set the size of the texture map to 2000×2000.
  4. Select the folder for your file, name your file, and select PNG as file format ( I recommend choosing RGB 24 bit as color depth. Alpha channel is not needed. ).
  5. Click ‘OK’ to save the file.
Texture painting workflow

Step 12 Painting on the Reflection Color Map

Now there is a blank texture in the reflection color channel. In reflection color channel we paint matte areas with black and shiny/reflective areas with white. Let’s paint some drool:
  1. Activate the Paint ( brush ) tool.
  2. Select white color.
  3. Select rather large Radius ( CTRL + SHIFT + Right-click and drag. Suitable radius depends on the zoom level ).
  4. Make sure Hardness is set to zero.
  5. Open the ‘Layers Dialog’
  6. Create and select a new layer.
  7. Paint around the mouth to create some drool.
  8. Activate the Fill tool.
  9. Select black color.
  10. Select the Background layer
  11. Click on the model to paint it black. ( keep in mind that in the paint mode you see just the paint. The final reflection effect is seen only in rendering. )
  12. Deactivate the Fill tool ( to deactivate the paint mode ). A new dialog appears. Select ‘Save as PSD and replace texture in material’. Now the file is saved as PSD and applied to the reflection color channel in the material.
Painting reflection map

Step 13 Reflection Glossiness Map and Bump map

Let’s make the texture more interesting by adding a reflection glossiness map and a bump map:
  1. Open Material Editor ( Press ‘m’ in keyboard )
  2. Go to the ‘General Maps’ rollout and drag and drop the texture we just created from ‘Reflection Color’ to ‘Reflection Glossiness’. Select ‘Instance’ when asked.
  3. Go to the ‘Special Purpose Maps’ rollout and set the bump value to 0,05.
  4. Now we’re going to create the bump texture in Photoshop. Go to Photoshop and open the diffuse texture we created earlier (PSD).
  5. Make a duplicate of the diffuse texture ( Image > Duplicate… ).
  6. Close the original and work with the duplicate. Delete all layers except the one we created and applied in steps 7-8. Change the blending mode of the layer from Overlay to Normal and Opacity to 100. Save it as PNG file.
  7. Go back to 3ds Max and add the new file to the Bump channel ( Maps > Standard > Bitmap > bump.png ).
Creating material
Now the material is complete and we go on with the lighting and rendering.

Step 14 Lighting and Rendering Setup

We’re going to use a basic three-point lighting setup to illuminate the monster. Since this is essentially a texturing tutorial I’m not going to go through the lighting in detail but I’ll give you the exact settings you can use:
  1. Key light: Mental Ray Area Spot ( Create panel > Lights > Standard > mr Area Spot ).
    Intensity/Color/Attenuation > Multiplier: 1,5
    Area Light Parameters > Height: 200
    Area Light Parameters > Width: 200
  2. Rim Light: Mental Ray Area Spot ( Create panel > Lights > Standard > mr Area Spot ).
    Intensity/Color/Attenuation > Multiplier: 1,4
    Area Light Parameters > Height: 200
    Area Light Parameters > Width: 200
  3. Fill Light: Skylight ( Create panel > Lights > Standard > Skylight ).
    Multiplier: 0,4
    Sky Color: pure white
  4. Drool Light: Omni ( Create panel > Lights > Standard > Omni ).
    Advanced Effects > Diffuse: Off
Three point lighting
Let’s adjust the sampling settings to get a polished render. Go to the render setup and increase antialiasing quality by increasing Mental Ray’s sampling values ( Rendering > Render setup… > Renderer > Sampling Quality ):
  • Samples per pixel
    • Minimum: 4
    • Maximum: 64
  • Filter
    • Type: Mitchell ( For most scenes the Mitchell filter gives the best results. ).
Finally change the background color to black ( Rendering > Environment… > Common Parameters > Background > Color) and hit render. Below you see the final rendered image. I made some color correction in Photoshop as well:
  • Brightness: 40
  • Contrast: 20
Texturing tutorial
Thanks for reading!

Thursday 22 June 2017

UNWRAPPING

This is the second tutorial of my four part series dealing with character animation. These tutorials are targeted for beginners wanting to learn the basics of organic  In this second part we’re going to unwrap the character. You’ll learn about UVW texture coordinates and unwrapping. I’ll do my best to keep things as simple as possible. I’m using 3ds Max 2011.

Step 1 What is Unwrapping?

In 3d graphics, mapping coordinates ( often called UVW coordinates or just UVWs ) define how the texture is wrapped around the model. Unwrapping means laying out the mapping coordinates so that texture painting can be done. While unwrapping a model one should pay attention to two things: stretching and seams. Naturally there must be seams when a 2d texture is wrapped around a 3d model. However, during the unwrapping process, one can define the amount and position of the seams. The goal is to have as few seams as possible and to hide them as well as possible (in the back of the model, under arms etc.).
The UVW mapping coordinates can ( and often do) make the texture stretch. During the unwrapping, the stretching should be minimized by moving the mapping coordinates. Often when there are lot of seams there aren’t that much stretching and vice versa. One must make a compromise between these two issues. In my opinion seams is the lesser evil and can be fixed easily with a 3d paint as you’ll see in my upcoming texture painting tutorial.
In the picture below you see the result of this tutorial. There are the unwrapped UVW coordinates on the left and the model with the UVWs and a checker texture on the right.
UVW Unwrapping

Step 2 Preparing the Model for Unwrapping

It’s always easier to unwrap a low poly model than a high poly model because there are just as many mapping coordinates as there are vertices. Therefore, it’s often a good idea to do the unwrapping before applying the Turbosmooth modifier. However, there is a one problem with our monster model. It changes pretty much when the first Iteration of the Turbosmooth modifier is applied. In fact, the arms change so much that there’d be some visible stretching in the final model if we unwrapped the low poly version. Fortunately there is an easy solution. We can set the Iterations value in the Turbosmooth modifier to 1. That’s a good compromise – polygon count isn’t yet high and the model is very close to it’s final form. Additionally, we want to do the unwrapping before applying the Symmetry modifier. The Symmetry modifier saves our time by mirror both the geometry and the mapping coordinates. Let’s prepare the model for the unwrapping:
  1. The starting point should be a 3ds Max file with just one object in it: Half of the monster with the Turbosmooth modifier applied.
  2. Set Iterations value to 1 in the Turbosmooth modifier.
  3. Add the Edit Poly modifier on top of the Turbosmooth modifier.
  4. Activate the polygon sub-object level in the Edit Poly modifier and delete the right half of the model in the front viewport ( see the image below ).
  5. To keep things simple, collapse your modifier stack ( right-click on the modifier stack and select collapse all from the menu ). If you want to keep your stack you can, but we’re going to add several new modifiers to it.
Low polygon model

Step 3 Checker Texture

Usually a checkerboard texture is applied to the model before the unwrapping. The checker texture makes it really easy to notice stretching. Open Material Editor ( Press ‘m’ in keyboard ) to create the checker texture for our model:
  1. Select your monster and assign a new material to it.
  2. Add Checker as a diffuse map ( Maps > Standard > Checker ).
  3. Set U and V Tiling to about 20 ( Stretching is easier to see in small squares ).
  4. Enable “Show Standard Map in Viewport” ( Makes the texture visible in shaded viewports ).
  5. Self-Illumination: 25 ( Makes it easier to see the checker pattern in dark areas such as inside the mouth. Change this as you see fit).
UV checker texture settings in 3ds Max
Now that the checker texture is applied, our goal is to organize the UVW coordinates so that all squares in the checker pattern are equal in size and are as square as possible.

Step 4 Unwrap UVW

The Unwrap UVW modifier is a powerful tool that let’s you apply many different mapping types to different face selections and you can even tweak individual mapping coordinates. In our workflow we make a face selection, apply the most appropriate mapping type to it, and tweak the mapping coordinates in the ‘Edit UVWs’ dialog. Let’s make a selection to be unwrapped:
  1. Apply the UVW Unwrap modifier to the model ( Make a selection > Modify panel > Modifier List > Object-Space Modifiers > Unwrap UVW ).
  2. Activate the face sub-object level in the Unwrap UVW modifier.
  3. Select everything except the arm ( Turn ‘Ignore Backfacing’ off to speed up the selection process. You can name your face selection using the ‘Named Selection Sets’ function on the main toolbar. It makes it easy to return to your selection. ). Orbit around the model to make sure you haven’t missed anything.
Selecting torso in UVW Unwrap modifier

Step 5 Pelt Mapping

In this tutorial we’re going to use Pelt mapping. Pelt mapping is a special mapping type that is well suited for organic models. Pelt mapping tools let us define the texture seams and stretch out the UVW coordinates into a flat, unified map:
  1. While the torso is still selected, click ‘Pelt’ ( Unwrap UVW> Map Parameters > Pelt ). In the ‘Edit UVWs’ dialog you see the UVW coordinates in the middle and a circular stretcher around it. The points in the stretcher are connected to the UVW map seam. The job of the stretcher is to pull the UVW map flat. The stretcher can be manipulated but in this case there’s no need.
  2. Look at the checker pattern in your model. There is serious stretching at the top and at the bottom of the model.
  3. Click ‘Start Pelt’ , let the simulation run for a few seconds, and click ‘Stop Pelt’.
  4. Look at the checker pattern in your model. It looks better, but there is still stretching and and squares aren’t uniform in size.
  5. Click ‘Start Relax’ and let the simulation run some time but stop it before the UVW vertices in the corner of the mouth overlap too much ( see the image below ).
  6. Look at the checker pattern in your model. If it looks ok click ‘Commit’.
Pelt mapping interface

Step 6 Edit UVWs Dialog

The face selection in the Unwrap UVW has been translated to a UVW coordinate selection in the ‘Edit UVWs’ dialog. Before manipulating the UVWs, let’s apply a few settings to make things a little simpler:
  1. Activate ‘Filter Selected Faces’ in the bottom of the dialog. ( Hides all UVWs except the ones we have selected ).
  2. Click ‘Options…’ in the bottom of the dialog to expand the options panel.
  3. Turn ‘Tile Bitmap’ off in ‘Bitmap Options’. ( Makes the whole dialog easier to understand ).
  4. Turn ‘Constant Update’ on in Viewport Options. ( Enables real time updates when moving UVWs ).
  5. Use the Move and Scale tools to fit the selected UVWs inside the texture boundaries. Also, rotate the UVW map so that the right side is as vertical as possible ( It makes the stitching in step 11 a little easier. ).
Edit UVWs dialog

Step 7 Dealing with Overlapping UVW Coordinates

The checker pattern should look really good, but unfortunately there might be some overlapping UVW coordinates or inverted faces. Let’s run two automatic error checking routines to find these problems:
  1. Select Inverted Faces ( ‘Edit UVWs’ Dialog > Select > Select Inverted Faces ).I didn’t find any but if you do, fix it ( see steps 3 -4 ).
  2. Select Overlapped Faces ( ‘Edit UVWs’ Dialog > Select > Select Overlapped Faces ).In my model there is one overlapped face in the corner of the mouth ( Overlapping UVW coordinates are a problem because they use the same portion of the texture ). Let’s zoom to the problem area and fix it.
  3. Activate the vertex sub-object level in the Unwrap UVW modifier.
  4. Move the vertices so that the problematic UVW faces look more like rectangles ( See the image below ). Check your model to make sure the checker pattern didn’t get messed up. When you’re done just close the ‘Edit UVWs’ dialog.
Moving UVW coordinates

Step 8 Defining UV Seams for Pelt Mapping

Now the unwrapping of the body is complete and we go on with the arm. By default the only seam in the arm is at the edge of our selection. That isn’t enough. The stretcher wouldn’t be able pull the UWV map flat. Try to visualize it in your head: It’s like trying to turn a sock into a flat piece of fabric without any cutting. But with just one cut we could do it, right? So let’s define one seam:
  1. Activate the face sub-object level in the Unwrap UVW modifier and select the faces of the arm. Orbit around the model to make sure you haven’t missed anything.
  2. Activate ‘Point to point Seam’ ( Unwrap UVW > Map Parameters > Point to Point Seam ) and define the seam for pelt mapping. Just click on vertices and a seam is traced between them. Defined seams are shown in blue color (See the image below ). There should be 10 edges in your seam. Make the seam under the arm, not on top of it. If you make a mistake you can activate ‘Edit Seams’ ( Unwrap UVW > Map Parameters > Edit Seam) and remove unwanted seams by clicking on them while pressing Alt in keyboard.
Defining UV seams

Step 9 Unwrapping the Arm

From now on the pelt mapping process is exactly the same as with the torso except there probably won’t be any overlapped nor inverted faces.
  1. While the arm is still selected, click ‘Pelt’ ( Unwrap UVW > Map Parameters > Pelt ).
  2. Click ‘Start Pelt’, let the simulation run for a few seconds, and click ‘Stop Pelt’.
  3. Look at the checker pattern in your model. There is probably stretching and the squares aren’t uniform in size.
  4. Click ‘Start Relax’, let the simulation run for a few seconds, and click ‘Stop Relax. ( see the image below ).
  5. Look at the checker pattern in your model. If it looks ok click ‘Commit’.
  6. Move and scale your UVW selection so that it doesn’t overlap with the UVWs of the torso.
  7. Scale the UVWs of the arm until the size of the squares is the same as in the torso ( you can choose whether you work in face, edge, or vertex level. Personally I prefer the vertex level )
  8. Arrange to UWV coordinates for example like in image below ( you can easily select a whole cluster of UVWs by activating ‘Select Element’ under ‘Selection Modes’ in the bottom of the dialog ) and close the dialog.
UV coordinate layout

Step 10 Mirroring the UV Coordinates and the Geometry

Now the unwrapping is done and we’re ready to apply the Symmetry modifier:
  1. Go to the front viewport and apply the Symmetry modifier ( Make a selection > Modify panel > Modifier List > Object-Space Modifiers > Symmetry ). If the model disappears, activate Flip ( Symmetry > Mirror Axis > Flip ).
  2. Activate the mirror sub-object level in the Symmetry modifier and align the mirror plane to the right side of the model. The vertices in the middle are welded together. Deactivate mirror sub-object level.
Mirror UV coordinates with the Symmetry modifier

Step 11 Tweaking the UVW Coordinates

Add another Unwrap UVW modifier on top of the Symmetry modifier ( Make a selection > Modify panel > Modifier List > Object-Space Modifiers > Unwrap UVW ). Click ‘Edit…’ in the Unwrap UVW modifier to open the ‘Edit UVWs’ dialog ( UVW Unwrap > Parameters > Edit… ). The UVW layout looks exactly the same as before the Symmetry modifier, but it’s not. The UVW coordinates of the both sides are exactly on top of each other and therefore use the same portion of the texture. This would be ok if we wanted the texturing to be perfectly symmetrical. Usually you want to separate the coordinates to avoid perfect symmetry:
  1. Activate ‘Select Element’ in the ‘Selection Modes’ at the bottom of the ‘Edit UVWs’ dialog.
  2. Click on the UVW map of the arm and move it to the right. Now you have separated the UVW clusters of the arms. Click ‘Mirror Horizontal’ in the top of the dialog ( this isn’t necessary but in my opinion a logical way of arranging the UVW coordinates ). Move the UVW clusters of the arms as you see fit. Just make sure to keep them separated and inside the texture boundaries.
  3. Click on the UVW map of the torso and move it to the right.
  4. Click ‘Mirror Horizontal’ in the top of the dialog to mirror the selected UVWs horizontally.
  5. Move the UVW clusters of the torso close the each other so that the middle vertices overlap ( see the image below ). These UVW coordinate clusters have a common seam in the middle and therefore can be welded together.
  6. Deactivate ‘Select Element’ in the ‘Selection Modes’ at the bottom of the dialog and weld the vertices on the common seam together ( see the image below ): select two vertices at a time, double click on them, and select ‘Weld selected’ from the menu. If the weld doesn’t work, the vertices are too far apart and you must increase the ‘Weld Threshold’ in the ‘Unwrap Editor Options’ at the bottom of the dialog.
  7. If the welding caused stretching in the middle, go ahead and move UVW vertices to fix it.
  8. It’s possible that one or more UVW clusters are inverted which might cause problems with bump mapping. Activate the face sub-object level and click ‘Select Inverted Faces’ ( ‘Edit UVWs’ Dialog > Select > Select Inverted Faces ). If any of the UVW clusters turns red, just mirror it horizontally and you’re done.
  9. Move and scale the UVW coordinate clusters so that they fill as much of the texture area as possible. There is a tool for that called ‘Pack UVs’ ( Edit UVWs Dialog > Tools > Pack UVs… ) but let’s do it by hand. Move and scale the UVW clusters as you see fit but whenever you scale, scale everything to keep the coordinate resolution uniform.
Weld UV coordinates

Step 12 Good to Know

If you just want to finish this, skip to step 13, but if you’d like to learn about the other mapping types, read on. In this tutorial we used Pelt mapping. Pelt mapping works well but sometimes there is a need also for the traditional mapping types: planar, cylindrical, spherical, and box. The workflow with these mapping types is a little different:
  1. You make a face selection.
  2. You apply the appropriate mapping type ( depends on the form of the selection, for example cylindrical selection like an arm works well with the cylindrical mapping type ).
  3. You move, scale, and rotate the mapping gizmo to minimize stretching and to position seams ( With these mapping types you can’t define seams like we did with Pelt mapping. Instead, seams are derived from the mapping gizmo. You can just manipulate the gizmo to affect the placement and the amount of seams ).
  4. You continue in the ‘Edit UVWs’ Dialog and move UVWs to minimize stretching and weld them to get rid of seams. Sometimes you must move UVW vertices one by one but often the Relax tool ( Edit UVWs Dialog > Tools > Relax… ) solves stretching automatically. The Relax tool works like the Relax in the Pelt mapping dialog. First you select UVWs in the problematic area ( and maybe little around it ) and then you run the Relax to modify the spacing of the selected UVWs for the purpose of minimizing stretching. Trial and error method works well with the Relax tool. Just try different selections and different settings.

Step 13 Turbosmooth

Now the UVW Unwrapping is complete. Add the Turbosmooth modifier to the model and set the Iterations value to 1-2 depending on your needs.
Unwrapped UVs
Let’s continue in the comments and stay tuned for the texturing tutorial!