3D World

Tutorials

Create realistic CG cloth

-

01 Grid creation

The goal of the model is to generate the weaves of the fabric. These are divided into warp (vertical lines) and weft (horizontal ones). The easiest way to create these weaves is to generate them using Curves so that you can make any adjustment­s, and then convert them into polygons.

For the base of the model, you need to create a tiled texture, so first create a grid of curves. You can decide on the spacing but the important part is to have the same amount of control points and distance between the curves. Use Maya to create a 12-unit curve, with a distance of one Maya unit between each of them. After that, just select rebuild with 12 spans and that will result in one control point per Maya unit.

Now it’s time to look at the pattern you want to achieve, which depends on the type of cloth. The informatio­n that you need to fill this pattern is given by the yarn weaves.

02 setting the weave pattern tile

Once you have your pattern, it is time to adjust the grid to follow the weave design. This part can be a little tedious, but it’s really important. You can define the colour pattern that you want to use for your cloth and if there’s a specific shape you need or want to make, remember to tile the result.

The warps should be tighter than the wefts, as they normally define the tension on the fabric. A little movement is good for the warps but try not to overdo it too much as this will result in loose fabric.

03 converting to polygons

When you have your grid and pattern done, and you’re sure it’s tiled, the next step is to generate the polygons for the render. Create a simple curve and snap it to the start of each curve, set the size the yarn shape should look – normally it’s not a perfect circle, more like an oval shape because of the tension. Selecting both the circle and the main curve, just extrude as polygons with enough subdivisio­ns to give a nice, smooth result.

Generate the polygons per curve and adjust the curves if you have any intersecti­on. The models should not touch or intersect each other.

04 setting up the id and Depth maps

Now that we have the model, it’s time to set up the map for the ID selection and the depth map. As a common colour setting the

The more data the better When creating the depth pass, try to get as much informatio­n as you can from it, and make sure you get good values in the gradient for better results.

warps and wefts use the red and blue channels respective­ly. For this process, you can set a surface shader with the colours on the models depending on the direction, or work with a puzzle matte AOV (Redshift renderer uses the puzzle matte AOV); this doesn’t depend on anti-aliasing and will give a cleaner result. Just set the AOV, with the R channel rendering the warps and the B channel for the wefts.

Set the camera on an orthogonal view, and render from the top. Try to achieve a tile and ensure that the weaves look as straight as possible. Now set a Zdepth pass to render the informatio­n from the model to use later in Nuke.

05 composing the maps in nuke

The next step is to generate one image using all the informatio­n for the depth map, and the ID maps for warps and wefts. To make the image map you need to import the maps into Nuke. The shader network that you are going to use later depends on the RGB channels to make the selection. For the warps and wefts, maintain the R and B channels, but for the depth, use the G channel. (With textures.xyz, the depth channel goes into the alpha and the G channel has fibres). Grade the Zdepth until you have a balance between the white and black values, check the deformatio­n that you will generate for the displaceme­nt map and try to leave a smooth gradient.

Once you have your depth map, merge the informatio­n into the Green channel of the puzzle matte. The result should look something like image 05b. Note that if you have a lot of dark blues it means that the warps are not tight enough.

06 material creation: base material

I am going to work with Redshift for the base material, but any render system should work fine. The first step here is to create a Rsmaterial and add a custom Fresnel curve. Then create a sampler info and a remap Value, and connect the facing ratio of the sampler info into the input colour of the Remapvalue. This will create the custom Fresnel curve. Next, edit the curve to follow the image as the fabric texture has low to no reflection on 0 Degrees and almost full reflection on 90 Degrees. Set the input min and max values so that they have the same behaviour as the image.

Connect the out.value to the reflection colour of the Rsmaterial (With V-ray remember to uncheck Fresnel to make it work correctly). Finally, set the roughness to a value close to 0.6 to adjust the overall look of the cloth material.

07 make the map network for the colour id

Create a file and look for the map that we exported from Nuke. Create a layered texture and create two slots on the layered texture node. Connect the Out.colorr of the file to the Alpha of the Input0, and the Out.colorr to the Alpha of the second slot. This will mask the slots to use the IDS from the map, and then you can adjust the warp and the weft accordingl­y.

Set both inputs to over to let the informatio­n pass through the node and textures. You can change the colours of the inputs to see if they are working correctly. Finally, add a new input at the end of the network, change its colour to black and connect to the colour input of your material. (If you mix the R and B channels, the result will give you the alpha informatio­n.) Control the repetition of the file accordingl­y.

08 creating the reflection map

Duplicate with incoming connection­s the colour layered texture and add a luminance node at the Out.color. Connect the Out.value to the Refl.weight of the Redshift-material.

material ids Each colour of the map drives certain informatio­n: The red channel is an ID pass for the warp, the blue channel is an ID pass for the weft. Use them as IDS on your material network for colour changes or different noises as masks.

On the Reflection­map adjust the colours to black and white, and test your render to look for a result that works for you. I prefer to work on this stage with no colour on the material to see the reflection­s in Redshift. For more informatio­n and better reflection, you can add a fractal or procedural node as new inputs to the layered texture.

09 Displaceme­nt map

With the colour and reflection informatio­n ready, it’s time to add the displaceme­nt informatio­n. Connect the G Channel to a displaceme­nt Shader node, and connect it to the Shading Group of the Redshift Material. Next, activate the displaceme­nt calculatio­n according to your render system (I used Redshift’s default settings).

10 procedural yarn twist

The fabric is ready. If you want to add the last bit of realism, you can use some procedural noise to make the twist effect on the yarn. First, create a ramp, make nine divisions and configure the colours to look like cylinders with the gradients. This are going to be the yarn twist.

For the yarn repetition, repeat the texture 12 times per main texture division, giving you around four twists per weave. To do that connect the repeat V from the main File and use a multiply divide node, multiplied by 12. Connect the Output to the Repeat UV of the Ramp place2dtex­ture.

Now, on the place 2d Texture node of the ramp, change the Rotate Frame value to 45, making the twist diagonal. Duplicate with connection­s the place2d texture and the ramp nodes. Change the names to vertical and horizontal, and set Vertical to U Ramp. With this you can add noise to the waves of the yarn and add more detail.

11 twists as bump map

Now it’s time to add the details to the network. To do this, create a new layered texture, using the same input configurat­ion as the colour base, with three inputs. The first is the horizontal noise, with the R channel as Alpha (this will mask the noise to only the horizontal lines). The vertical noise is the second, with the B channel as Alpha for the vertical lines. Set both inputs to Add on the blend mode, and for the last, set the colour to black. Now for the final step: connect the layered texture to the bump map slot and correct the value until you are happy that the yarns look realistic.

12 mixing layered textures

If you want even more detail, you can mix the informatio­n of the three main layered textures (colour, bump and reflection), adding the informatio­n of the bump to the colour. You can also mix the bump with the reflection and this will help you with the realism of the shader, and you could add some fractal noises to the colour so that the reflection will help to break the pattern and unify the overall look of the cloth. This technique can be seen in the video tutorial that you can access with the custom code provided earlier.

adding twists The twists are going to help you to really boost the level of realism on the fabric, even closeup; be sure to rotate them 45 degrees to simulate the yarns.

 ??  ?? 06
06
 ??  ?? 05a & b
05a & b
 ??  ??
 ??  ?? 07a & b
07a & b
 ??  ??
 ??  ?? 02a
02a
 ??  ?? 01
01
 ??  ??
 ??  ??
 ??  ?? 04a
04a
 ??  ??
 ??  ??
 ??  ??
 ??  ?? 09 08a & b
09 08a & b
 ??  ??
 ??  ?? 11
11
 ??  ??
 ??  ??
 ??  ?? 09 10a & b
09 10a & b

Newspapers in English

Newspapers from Australia