« Posts tagged Cloth

[Game] Tombstone WIP 3 – Cloth

Maya Cloth Skeleton

Blowing Scarf (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/tombscarf NULL.jpg)Since my last update I’ve added a cloth skeletal mesh to the scene. Cloth inside the Unreal Development Kit is something I’ve always wanted to take a look at.  After watching a quick tutorial over at 3D Buzz (http://www NULL.3dbuzz NULL.com/vbforum/sv_showvideo NULL.php?v=3830) I was ready to start setting up my cloth in Maya. The video is good, but it skips the entire rigging process and starts with a pre rigged 3D plane brought into the UDK. I looked around on the internet for some Maya specific tutorials, but there weren’t any. The first thing that caught me while working this out was the use of the term “bone“. A lot of the tutorials instruct  the reader to add two bones to the mesh. In Maya you don’t really lay down bones. You’re laying down “joints” and what I would consider the bones are the shapes Maya creates between those joints. Before you start you’re probably going to want to jump into Maya’s Animation tab so all the rigging tools are on your shelf. The first step in Maya is to place two joints in a chain along the X axis fairly close together. The next step after you’ve created these joints is to use a “smooth bind” to pair the joint chain with your mesh. That command is under the Animation Menu > Skin > Smooth Bind. Now with the joint chain bound to your mesh you can begin to “paint” your vertex weights. After being bound each joint in the chain stores a separate value for each vertex. Every individual vertex value lets the joint know how much influence it should have over that particular vertex. A value of 1 means the joint would act upon that vertex with 100% of it’s influence (or movement). A value of 0 means that the vertex will not follow that particular joint at all. Below I have a diagram showing how your joints should be setup and named. UDK will later ask us which bone we want associated with the cloth movement.Maya Cloth Skeleton (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/bonesetup NULL.png)

Now that the mesh is rigged go into “Object Mode” and use the right click menu to access the “Paint Skin Weights Tool“. Make sure you have textures enabled in your viewport when you’re doing this. You also have to be in the “Default Quality Rendering” mode under your perspective views “Panel” menu to see the weights change as you paint. The first joint “bone1” is going to be associated with all the parts of your cloth mesh you don’t want to move. For my scenario I have painted all the vertices of the knot white and all the vertices of the two scarf arms black. I do this because I don’t want the knot to move at all.  I’ve included two diagrams below to show the weighting of my vertices to both bone1 and bone2.Bone one Weights (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/bone1 NULL.png)Bone Two Weights (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/bone2 NULL.png) After you’ve weighted your vertices you can export the mesh as a FBX for import into the UDK. On import the UDK should recognize your mesh as a skeletal mesh and give you a different window type when it’s opened up through the UDK Content Browser. After import there are a few properties you need to activate in your mesh.

First you need to open up your cloth mesh in the content browser. You should now have the AnimSet Editor open. This is because UDK is treating our cloth as a “Skeletal Mesh“. The first property we want to activate is “Force CPU skining” this will tell the UDK that we want our mesh to be treated as a cloth. It’s found under the “Skeletal Mesh” roll out in the “Properties” pane. The second and final property we need to change is under the “Cloth” roll out. When there expand the “Cloth Bones” roll out and hit the green cross to add an entry to the Cloth Bones list. Now click in the name space for that entry and call it whatever you named the second joint in Maya. In my case it was “bone2”. With this done you’re now ready to place your mesh into your game scene.Cloth UDK Mesh Properties (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/Scarf NULL.png)

Make sure your mesh is selected in your content browser and then right click in one of your views so that you may add your mesh to the scene. Once your mesh is in the scene you need to change a couple of it’s properties that we couldn’t access from the AnimSet Editor window earlier. Under the “Skeletal Mesh Actor” roll out there is a sub section called “Cloth” expand this. Under here we can Cloth In Game Mesh Options (http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/12/Scarf2 NULL.png)see the first option “Enable Cloth” and a lower option called “Cloth Awake On Startup“. Enable both these options. As an optional step you can play around with the wind values to try and get your mesh to receive a constant blowing force. To now see your cloth in action you can rebuild your map and launch the level, or simply right click in the perspective viewport and chose “Play From Here“. Cloth doesn’t animate in the viewport’s “Game Mode“.

That’s it for this Tombstone project. I hope anyone following along found some cool tips to help them get a little more out of the UDK.

Cheers,

Terry Matthes

Late Night With Mental Ray

(http://www NULL.terrymatthes NULL.com/wp-content/uploads/2012/09/TMNIGHT2 NULL.jpg)I have wanted to try a late night render for some time and I got an excuse to do so recently. A lot of the time went into getting the final gather and global illumination to behave correctly.  There are two area lights outside the windows lighting the scene along with the two point lights; one in each lamp. The lamp’s point lights have their colour temperature controlled by a mib blackbody node set to around. The floor panel is a flat plane using a 2D bump (no normals) to pop out the individual floor planks. Underneath it, a wood texture to support this.

The ottoman in the middle of the room is procedurally textured using the 2D Texture Cloth node to create a fine bump across the surface as well as to define the diffuse colour of the fabric. Some unevenness is applied to the 2D Placement Node of the ottoman’s material to simulate uneven stretching of the fabric. This effect is applied subtly though. A stronger effect is the light shining through the surface of the lamp shade. This was achieved through using Maya’s default translucent property on a simple lambert shader. A yellowish colour was then picked for the diffuse and I turned down the diffuse value of the material to around “0.4”. The area light to the right of the scene is colored with a dim blue light to simulate the way your eyes desaturate colours in low light conditions. A blue tint was also added afterwards to the whole image in Photoshop. To achieve the final gather I wanted I used three point lights that didn’t cast diffuse or specular light. These point lights simply cast photons (around 300k each) to paint the rooms with final gather points. One point light was placed in the middle of each room. Before rendering I made sure to save out both my final gather and global illuminations passes. The cat on the couch was done using Maya’s native fur system. If I were to change anything I think I would paint a custom fur length map for the cat so the hair wasn’t the same length all over.

In Photoshop I applied an ambient occlusion render over the entire image, set it’s opacity to around 30% and changed  it’s layer’s draw type to multiply. I rendered this image out and an EXR and it gave me the ability to really pull the values of the scene in a wide range due to the raw nature of an EXR. To select the individual objects in the scene I rendered out a mask pass to make selecting the individual elements of the scene much easier. The mask pass was made as a separate render layer. I made 5 different Maya surface shaders and labeled them: red, green, blue, black, and white. I then applied these shaders to everything in the scene and made sure that no to objects with the same colour overlapped.

If anyone has any questions feel free to comment below or to contact me about the questions. Have a nice day :)