Search This Blog

Welcome to Rendering Tutorial Site

Welcome to Rendering Tutorial site. This site is develop to help artist, architects, advertisers, visual artists and hobbyist a place to share, gain and learn from tutorial writers, important knowledge, tricks and tips in using rendering and image processing software. Some of the link here were cross posted from other sites, some of them were develop for this site, and some of them were shared wholeheartedly by different individuals.

Monday, 26 March 2012

Material Masking

Material Masking by
Ted Boardman 

Who was that masked material?
Masking is the process of hiding and revealing portions of a pattern using the luminance values of another pattern or map. The concept is simple, as is the fundamental application, but by using masking upon masking you are able to generate very complex materials that are convincing to the viewer.

This column will introduce you to the process of masking at both the map and the material level in 3ds max or Autodesk VIZ, both programs share the same capabilities. We will start with the simple applications to see how masking functions, then work into more complex examples including animated masks.

Grayscale images generally function best as masks. It is the Luminance value of a pixel that controls the masking effect, white is opaque…black is transparent…levels of gray are somewhere in-between. Color images may be used as masks, but it is very difficult for most of us to judge a particular luminance value of a color. For example, green and yellow look very different, but might have the same luminance values and would be ineffective as a mask.

As with all topics in max or VIZ it is best to start simply to get a feel for the functionality and controls, then work into more complex applications. I will include a VIZ 4 file for downloading that can be opened in either VIZ 4 or 3ds max 4 and 5. For those of you with previous versions of max or VIZ the descriptions should be enough for you to build your own similar scenes and examples.

Where can masks be applied?

Masking can occur at either the map or the material level. If masks are applied at the map level the effect is only for that particular material component; Diffuse Color, Opacity, Reflections, etc. The material masking allows all components of materials to be hidden or revealed by the mask.

Two examples of masking at map level would be the Mask map that allows one map and one mask that allows the underlying Diffuse Color to show through and the Mix map that allows two maps with an optional mask. Another map type called Composite can be used for masking effects that use image Alpha Channels that will act as the masking agent. Alpha Channels will be discussed later in the column.

At the material level my favorite is the Blend material that allows two materials with a mask. This allows you to reveal two separate complete materials with different color, bumps, reflections, for example, with the mask.

The depth of masking is unlimited, for example you can have a mask map within a mask map within a mask map or a Blend material made of a material plus another Blend material, each with it’s own mask. Like I said earlier, though, start simply and build on your knowledge as you become comfortable with the process.

Masking at map level

As mentioned, there are several methods for applying masks at the map level of a material and the one we’ll look at here will be the Mask map.

The scenario is a tile floor with solid red tiles alternating with marble pattern tiles and can be accessed by downloading Tile_viz4.max. (Download zip file at end of article) The red color will be set as the Diffuse and Ambient Color swatches of the material. A Mask map is applied to the Diffuse Color slot and is composed of a Perlin Marble map and a Checker mask. The white areas of the Checker mask are opaque and show the marble map. The black areas of the Checker mask are transparent and reveal the underlying solid red Diffuse Color. See Figure 1.

 
Figure 1: The Material Editor shows a Mask map in Diffuse Color slot that contains a map and a mask. The viewport and rendered image show the effect of black and white masking of the map. Perlin Marble shows in the white areas and diffuse red shows in black areas.
 
This example shows how the process works in a Diffuse Color example. In the next example I use a Mask map in conjunction with a Raytrace reflection map on a tile floor that can be found in Wall_viz4.max. The scenario here is a ceramic tile floor with Brick maps defining the color and the bump pattern and a Raytrace map that causes the material to reflect its surroundings.

In the Mask map of the Reflection slot I have disabled the Bricks mask by unchecking it in the Mask Parameters rollout causing the reflection to be the same for both the tiles and grout. See Figure 2.


Figure 2: The mask of the floor tile Reflection slot has been disabled and you can see the reflection of the cylinder is the same in the grout and tile.

By applying the same Brick map I used in the Bump slot of the material to a Mask map with a Raytrace map, the reflections only occur in the white areas of the mask. See Figure 3.


Figure 3: Enabling the Bricks mask reveals reflections in the tile areas but not in the grout areas for a more convincing floor material.

Masking at the material component level offers a lot of possibilities for experimentation. The same Reflection masking as above could be used with Raytrace and a Noise mask to give the illusions of puddles on a road surface. A combination of Bricks map in the Bump slot with a Gradient Ramp mask could create the illusion of a knurled surface on a tool handle. Use your imagination and experiment.

Masking at the material level

Masking at the material level functions the same as at the map level but increases the control another notch. Each material can have widely varying attributes like color, shininess, and bumps, each revealed or hidden by the mask. In the example here I’ll use the Blend material with the optional mask.

The scenario will be a wall that needs a combination of brick and stucco. As in most projects the exact material placement will be held in secret by the designer right up to the last minute of the deadline. I want to be able to make last minute changes quickly and easily. This is also using the file Wall_viz4.max. (Download zip file at end of article)

Blend material with masking allows us to do this nicely. I create the Blend material with a Brick and a Stucco material, each with different patterns, colors, and bumps. I’ll use a Gradient Ramp mask that has been adjusted for solid bands of black and white to reveal the two materials exactly where I want them on the model.

This wall example also illustrates a powerful feature of max and VIZ called Map Channels. Because the patterns of the brick, the stucco, and the mask repeat differently over the wall surface I needed different mapping coordinates for each map. The wall has three UVW Map modifiers each set to a different Map Channel. The Gradient Ramp mask is set to use Map Channel 1, the Brick map uses Map Channel 2, and the Stucco map uses Map Channel 3 so that each pattern may be adjusted independently. The Map Channel in the UVW Map must match the Explicit Map Channel setting of the map in the Material Editor.

The Gradient Ramp map has been rotated in the W axis in the Coordinates rollout for proper orientation on the wall. An alternative would be to rotate the UVW Map modifier Gizmo.

Figure 4 shows the Gradient Ramp map and the rendered image shows the result of the masking. Each material has it’s own color and bump information.


Figure 4: A Blend material with a Gradient Ramp mask reveals Brick or Stucco at the appropriate location.
A simple change to the Gradient Ramp updates the position of the materials with no other adjustments needed. See Figure 5.


Figure 5: By adjusting the position of the flags in the Gradient Ramp map used as the mask, you can quickly reposition the location of the materials.

This same wall material could have been used with a Noise map to simulate a stucco wall with sections of plaster fallen off to reveal bricks below. You could also create the illusion of rust coming through a metal panel or grassy areas with patches of rock and dirt.

Animated masks

Masks do not have to be static images or maps. Interesting effects can be created by using animated masks in the form of avi or mov files or as sequentially number still images. You might say that it sounds logical, but you don’t have a 2D animation program to create the animated maps. Don’t fear, it is easy to create animated masks in 3ds max or Autodesk VIZ.

In the file called Rope_viz4.max (Download zip file at end of article) is a section of coiled rope made by lofting a circle around a helix and applying a material to it. The task at hand is to make the rope disappear over time, not all at once, but from one end to the other.

The solution here is to use a Blend material and a mask again. In the Blend material is a rope material and a material that is completely invisible. The opacity and glossiness of the material have been set to 0. It is important to set the glossiness to 0 to avoid a highlight on the invisible portion of the rope.

The mask is created in VIZ 4 by assigning a pure white material to a flat plane and animating the plane moving from just off screen to filling the viewport of a camera view. In this case it is Camera02. The animation was rendered as an avi file and used in the Mask slot of the Blend material.

Figure 6 shows the Blend material level in Material Editor and the result of rendering frame 15 of 30 frames. Half the rope that you see in the Camera01 viewport is invisible in the rendered image. See Figure 6.


 
Figure 6
The same technique could have been used to reveal a shiny new material under an old crusty material over time or to make a surface appear to bubble from the heat by revealing the base material with same material with a bump map added.

Note that it is important in this case that the rope be created in max or VIZ by lofting. Lofted objects are the only objects that generate mapping coordinates that allow the patterns to follow the curvature of the objects. For example the rope material and the mask both follow the rope as it winds upward.

Alpha channel and masking

You will often hear the term Alpha Channel in conjunction with maps in max or VIZ. It refers to information that is stored in certain bitmaps that determine transparency. The most popular files types with alpha channels are tga, tif, and png.

Computer generated images are displayed in pixels, either on screen or when printed. Since the early days of computer graphics anti-aliasing has been used to smooth diagonal lines and edges caused by stair-stepping across squarish pixels.

Anti-aliasing is done by blending the pixels at the edges of contrasting colors to make the edge appear smoother. If a red diagonal line is applied to a yellow background then some pixels are quite red with a little yellow, some are half red, half yellow, and others are quite yellow with a little red. This smooths the transition when seen from a distance.

However, if the red line is lifted from the yellow background and composited onto a blue background the yellow remnants look terrible and are worse than no anti-aliasing. 32 bit files or files with 24 bits of color and 8 bits of alpha channel use transparency pixels instead of the background color to create the anti-aliasing effect. Now when the red line with varying transparent pixels are composited to another background there is no problem and everything has clean edges that appear smooth.

Max and VIZ both can take advantage of files with Alpha Channel in the masks for a cleaner blend at either the map or the material level. Workings on the examples in this column don’t require Alpha Channel to work, but keep it in mind if you are experiencing problems with detailed masks in your explorations.

Summary

Masking gives you control of materials you never thought possible. The concept and application are simple at its base level, but by combining masks at different levels you can create materials that are complex yet easily edited.

As a personal plug, if you are a 3ds max 5 user, my new 3ds max 5 Fundamentals book by New Riders Publishing is set to appear in late October or early November. It is somewhat different than my previous fundamentals book in that I focus on the many new max 5 features in a series of exercises that take you from a medieval village to building a personal transporter, and a trip to the fortune tellers. The exercises are designed to be an interesting and informative way to learn uses for max 5 features from modeling, to materials and radiosity lighting, to collision detection and scene editing and compositing.

In any case, good luck and have fun!

Ted


Saturday, 10 March 2012

Tutorials:Adding variation to repeating textures
This tutorial will cover a method used to hide the repeating pattern of a texture using the unreal material editor.
Copyright: Free Use Category: Materials
Author: Chris Albeluhn Tags:

Chris repeatingTex-Image01.jpg

The image above is a before and after image of a texture for a floor. It is a little difficult to see the repeating texture, so if i repeat it 4 times, it will make it easier to see. 

Chris repeatingTex-Image02.jpg

Here it is VERY easy to see the repeating, and yes, this could RUIN the believeability of a game, however, there is a way to hide this. First off, you will want to decrease any obvious color repeating (drastic change in color or saturation of a color based on the other colors of the textures). For now, i will keep this texture how it is and simply play around with the other textures we will be using. 

First off we will need the original textures used to create this. I will be using the diffuse as a specular texture as well as the diffuse, and a normal map is required as well. On top of that, i will need two other textures to add variation. To create this, i played around with a black and white version of the original diffuse texture, repeated it 4 times (if it was originally a 512X512 texture, it then became a 2048X2048 texture. Once it's created, we will down size it back to 512X512, making a texture like the original, but repeated 4 times. I then created a normal map from that)
These are the images I am using. 

Chris repeatingTex-Image03.jpg As you can see, the bottom two images are a repeating version of the top two versions. I over laid different 'repeating' textures to create a variation that we can use to change how these textures repeat.

Here is a quick shot of the final shader. I will explain the steps and why certain nodes are being used.
Here is the break down: 

Chris repeatingTex-Image04.jpg

The multiply of them top 'Texture Sample' is 1/4th that of the lower 'Texture Sample'. The constant clamp is placed before the 'multiply' to clamp the black at a value of .25 (Clamp: Min - 0.025 Max – 1)
The multiply is then multiplied again by 'constant 3 vector' with the value of “0.8 0.7 0.5” to give it a slight colour change. 

Chris repeatingTex-Image05.jpg

The texture sample you see here can be any repeatable diffuse you want to add an aditional pattern noise to the shader. 

The 'TexCoord' node can be whatever you want, this will depend on your asset and what it looks like in the end. 

The constant clamp will be used to limit the 'dark' variation if it is needed. A multiply is added between the original multiply adding the two previous textures discussed above and the texture we are currently working with. 

Both the last multiply of the previous step and the multiply of this step is placed into the A and B channel of a Lerp node. 

Chris repeatingTex-Image06.jpg

In this step, the a constant variable is plugged into the Lerp node. This will blend evenly between the two multiply materials we have so far. That is then plugged into the Diffuse of the material. 

The Lerp is then plugged into the multiply which is then plugged into a Power node. This is done to gain more contrast, so the colors get richer and sharper. This will then become the 'spec' texture. 

Spec power is then set to whatever strength you'd like depending on your asset. For this one, it is set to 25 using a 'constant variable'. 

Chris repeatingTex-Image07.jpg

This step adds a variation normal map onto the existing floor normal map. This will add dents, creases, scuffs and other details that will add volume for the lights to play with. As shown in the image above (and covered in one of my other tutorials) this step is easy to set up. I will mention however that the "Constant 3 Vector" is used because the three numbers correspond to the RGB value of the texture. The higher the number, the more powerful the normal map will be. The R and G numbers should be even with one another, but the B value should be set to 0 nearly every time. The reason for this is because the more 'blue' you add to the original normal map, the flatter it will become, there for losing the detail you originally had. 

This is the final result. Some repeating is noticeable, but to fix this, tweak your diffuse textures to fit your desired look. Also, any grime layers you lay over this can be rotated slightly so they do not repeat along the same axis as the rest of your textures. 

Chris repeatingTex-Image08.jpg

Monday, 5 March 2012

Where to find Vismats

Vismats are Vray material files from VRAY Rhino and VRAY SketchUp.  When ASGVIS became part of Chaos Group, the VISMATS sharing site was gone. Their material was not available to non-paying users. Luckily you can still find some of the materials at Vray.com once you registered with them.
http://www.vray.com/vray_materials/

Some materials are also available at Flying architecture http://www.flyingarchitecture.com/vray-materials/
Some of the old ASGVIS materials are still here, plus some more materials done by FA.

Recently the library on this site: www.sketchupvraymaterials.blogspot.com started to file up. Check them out.