Using IFW2_Stencil II

Introduction
IFW2_Stencil II works in the same way as IFW2 Stencil, see tutorial six, except that it can key off any of the object's attributes such as the reflectivity, transparency or even the translucency. When the shader is applied Parameter 3 controls which object attribute the shader will key off. The following table details the values and the selected attribute:
ValueSelected Attribute
0Luminosity
1Diffuse
2Specularity
3Reflectivity
4Transparency
5Refraction Index
6Roughness
7Translucency
8Color Highlights
9Color Filter
10Additive Transparency
11Diffuse Sharpness

Step One
For this tutorial we are going use the fish model from the standard Newtek model directory, c:\lightwave\objects\characters\fish.lwo. You will notice that there are two fish so select the fish:layer1 object and delete it leaving just the fish:layer2 object. To show how IFW2 Stencil II works we are going to add an IFW2 texture to only the yellow stripes on the flank of the fish but leave the rest of the coloring alone.


Step Two
The first thing to do is create a mask image for the fish. This is the image that we will use as the stencil for our texture. Load the image map c:\lightwave\images\characters\fish_01.jpg into your favorite image editing program and select the yellow stripes for the flanks of the fish. Delete everything else leaving just the stripes, make the image grey scale and adjust the brightness and contrast to get a black and white image. Finally, blur the stripes slightly to feather the edges and save it as fish_01_mask.jpg.


Step Three
The next thing to do is add our new stencil image map to the fish. The easiest way to achieve this is by pressing in the color T button to bring up the texture editor for the color channel. Then pick the layer fish_01.jpg and then select Copy->Current Layer. Now, we are going to use the translucency as the attribute to key off so click on the translucency T next to bring the texture editor for the color channel. Then select Paste->Replace All Layers to copy the color image in the translucency channel. Finally, we just need to change the image to our stencil image so load and select fish_01_mask.jpg as the image for the current channel.


Step Four
Now that we have the translucency set up on our object add the IFW2_SpecialFX shader and select Stencil II. In order to key off the translucency we need to set Parameter 3 to 7 as per the table shown in the introduction to this tutorial. By doing this we have a texture function keyed to the object's translucency which, in turn, is mapped to our stencil image. In order to show this the image on the left shows a red/green/blue color map set up in the Stencil II shader. So all we need to do is create an alpha map based on this function to use as an material maps so simply set Alpha1 to 100% with Blend1 at 0% and Blend 2 100%. Also, ensure that all of the color enable check boxes are disabled in Stencil II so that is does not affect the color.


Step Five
The last thing to do is add the texture to be used in the stripes. For this I have used Nurnies from the IFW2_Space shader to make the texture application easier to see. To add the texture simply place the IFW2_Space shader after the Stencil II shader. Then set up how you want the nurnies texture to appear. Finally, once you are happy with how the nurnies look simply check the Material Map Layer check box under the Bump tab. What we have done is used the stencil to create an alpha map keyed of the translucency. Then we have added the nurnies and said use the alpha map set up by the stencil II shader as a material map. This has the effect of making the nurnies only appear in the stripes as per the images on either side.


Conclusions
One important point about Stencil II is parameter 4. This parameter sets the value that is applied to the selected channel after it has been keyed off. Say you wanted an overall reflectivity of 30% but you wanted key off a image in the reflectivity. Simply key off it and make Parameter 4 0.3 (0.3 is 30% i.e. 30/100).


Home Order About Pricing Mail Home Home Back