|
The rendering abilities demonstrated by Studio Pro have always been dependent on its incredible texturing system. One of this system's most powerful features is the ability to use a bitmap as a stencil to control the interaction of various textures applied to a single object. Stencils can also be used to control transparency as well. In this tutorial we will examine the uses of stencils in Studio Pro (version 2.5.3), how to create textures controlled by stencils, what making stencils really entails and the results that can be expected from various stencils. c r e a t i n g s t e n c i l s a n d t h e i r u s e s So what is a stencil? Basically it is a grayscale bitmap used to cutout a shape from another bitmap. Both bitmaps exist within the Surface Texture dialog of Studio Pro. ![]() Figure 1 : When creating a set of texture maps for use within Studio Pro it is essential that the various images register properly. For this reason a good bitmap editor, which will allow layering, is essential. In my own practice I use the stencil map as a guide for creating all of the other maps that I intend to use for any particular texture that uses a stencil. In the above example the diffuse color map (which appears both above the word 'map' and in the 'diffuse color' window) was made to fit the stencil map as shown. The tab 'stencil' allows the artist to choose between a stencil which allows the underlying texture to show through the black areas of the stencil map (so called 'white') or transparency for the black areas (not selected in this case). Stenciled textures have many uses. A stenciled texture can be used to allow the layering of more than one texture onto an object and to control transparency so that out of simple objects the artist can create complexity without the associated geometry. s o m e u s e s f o r s t e n c i l e d t e x t u r e s Limiting geometry is important in 3D art. If the artist is not careful his masterpiece can quickly become too complex to manage easily at the modeling level and impossible to render due to a large model size. One way to limit geometry is to use primitives as much as possible and to let an image map carry most of the information. Creating some leaves is a good example of this. Making a 3D tree can quickly tax all but the most powerful systems, if only because it takes so many leaves to make a tree believable. If the burden of believability is left to the image map, however, and the leaf geometry is simplified to a rectangular primitive approximating the size of the leaf, then the tree becomes much more manageable. (see Figure 13) Figures 2 through 4 (all Photoshop screen shots) show the creation of a leaf image map. ![]() Figure 2 : In this example a white background surrounding the leaf image will generate a rendering artifact : a white halo surrounding the leaf which will be visible in some cases. ![]() Figure 3 : In this example the leaf image from figure 2 is flattened against the same green contained in the leaf. This image will generate the fewest rendering artifacts. ![]() Figure 4 : This image (enlarged) shows the stencil for the leaf images in figures 2 and 3 which is used in this tutorial. It is purposely created to have aliased and antialiased sides. In many cases having antialiasing in the stencil will generate rendering artifacts. Creating a texture involves using the appropriate channels in Studio Pro's texturing dialog. In this case the leaf image (either figure 2 or figure 3) is placed into the diffuse channel and the stencil image (figure 4) is placed into the stencil channel and set to 'white' (see figures 9 and 11). u s i n g s t e n c i l s t o l a y e r t e x t u r e s The following figures show the use of two texture maps created from figures 2 through 4. In one texture the image in figure 2 is used in the diffuse channel and in the other texture the image in figure 3 is used in the diffuse channel. Both textures use the image shown in figure 4 in the stencil channel. ![]() Figure 5 : The above image was created layering three textures onto a primitive cube. The first (bottom most) texture was a simple color like that of the leaf applied to the cube. The second texture was created using the leaf image from figure 2 (with a white background) and the stencil from figure 4 (the stencil is set to 'white'in the texture dialog). It was applied as a decal, tiled once and positioned onto the front of the cube. The white outline caused by the stencil and the white background of the image is clearly visible. If you look closely, you can discern that the side of the leaf in which the antialiasing of the stencil is most prominent (the left side) has more white than the other side of the leaf where there is no antialiasing. The third texture was created using the leaf image from figure 3, it is otherwise the same as the second applied texture. It was applied as a decal, tiled once and positioned onto the top of the cube. As you can plainly see no white outline surrounds the leaf, even where there is prominent antialiasing in the stencil. As can be seen in figure 5, applying stenciled textures in which no transparency is involved can work very well as long as the image map used with the stencil is properly made. If, however, the stencil is used to create transparency around the image map then the rendering artifacts introduced by the antialiased stencil are more difficult to deal with. u s i n g s t e n c i l s t o c o n t r o l t r a n s p a r e n c y D) Using Stencils to control transparency. In creating a leaf for a tree, the modeler can conserve geometry by applying a stenciled leaf image to a rectangular primitive that approximates the size of the leaf. In this case, minimizing antialiasing in the stencil map is very important to obtaining good results. ![]() Figure 6 : In this figure the leaves on the left side of the image are generated from a texture map created from the leaf image in figure 2 and the leaves on the right side of the image are generated from a texture map created from the leaf image in figure 3. In both cases the stencil was set to 'transparent' in the texture dialog stencil pop-up. In both sets of images in figure 6, where the leaves overlap each other a faint white outline can be seen. The overlapping leaves on the right side look cleaner because the leaf image is flattened against the same green contained within the leaf. Also, in both cases, aliasing minimizes the white ghost, which even in the case of the leaves on the right side it is apparent where the stencil map is antialiased. Figure 6 (above) illustrates that an aliased stencil map which creates transparency generates the fewest rendering artifacts, especially when combined with a correctly made image map (one in which the image of interest is flattened against a similar color background). This aliasing is OK as long as the image that results is small enough in the final rendered output so that the jagged edges which result are minimized. However, if the image will be generated at a size so that the aliasing becomes important then the artist must compromise to some extent and antialias the stencil map just enough to balance minimal aliasing with a white outline. ![]() Figure 7 : In this figure the leaf textures of figure 5 are applied against a cube in which the lowest applied texture is a glass texture. The white outline of the front leaf (as seen in figure 5) is not apparent in this case. However, an artifact of the texture application is seen in this image. The leaves were applied as decals to the front and top of the cube but it is clear that images of the leaves are projected through the cube to their opposite sides which is contrary to what a texture applied as a decal should do. ![]() Figure 8 : This image was created with three textures applied to a simple sphere. Figures 9 and 10 illustrate the dialog settings used to generate the image in figure 8. Figure 11 shows alternate settings for the texture dialog which generate the same image. ![]() Figure 9 : Surface texture dialog with settings used to generate the image in figure 8. ![]() Figure 10 : This dialog shows the texture layers applied to generate the image in figure 8. The selected texture has been 'UV' (implicitly) mapped to the sphere. The coverage settings repeat the stencil about the vertical axis of the sphere. The 'number 1' layer is decal mapped (not shown) to the sphere with tiling set to a single instance of the texture. ![]() Figure 11 : The stencil settings shown in this screen shot generate a similar image as that shown in figure 8. ![]() Figure 12 : This image was created using a primitive cube mapped with four textures. It is reflected into a mirror so that the opposite side of the image can be seen. The number '1' was placed as a stenciled texture using 'decal' mapping and the number '2' was placed as a stenciled texture using 'planar (or pass-through)' mapping. Since these image maps contain no geometry, only the planar-mapped texture shows through. The decal mapped number 1 maps onto the opposite wall of the box but does not show-up in the reflection. ![]() Figure 13 : This image was created using an instanced rectangular primitive with an applied leaf texture map created using a stencil for the shape of the leaf (set to transparent). The mapping mode was set to 'planar'. ![]() Figure 14 : This image shows a rendering artifact which results when an environmental fog is present - the rectangles upon which the texture is applied become visible. This artifact is present whether or not the opacity channel of the texture dialog is used. ![]() Figure 15 : In this image the stencil map controlling transparency created an alpha map. In Photoshop this alpha map was used to composite the foreground image against a Bryce image. Clearly stencils can add a lot to the power of textures in Studio Pro. They can be used in layering many different textures onto an object, to control transparency on an object and as a modeling tool. Tom Babcock was trained in biochemistry and music and now makes his living doing art and animation for a small company in Berkeley, California. He can be reached at tbabcock@AOL.com. |