Thursday, May 5, 2011

Texture Overlay in Cheetah3D

The goal of this tutorial is to introduce some of the basic features of Cheetah3D's node system. In particular, I'm interested in demonstrating a way to add decals on top of existing textures. To my knowledge, this is the easiest way to do it. I've included links for the images I've used at the bottom of the tutorial. I've left them all intact, except for TrafficSigns0324_2_S.png, which I've opened in Photoshop, flattened it, and used the white eyedropper in the Levels dialog box to force the background into white. The reason for this is that compositing textures does not quite work the expected way when there's transparency involved.

Open a new C3D file, add a plane and a Sun Light. Set the camera and Sun Light options according to figures 1 and 2. The plane can be left in its default settings.

Figure 1. Set the camera's output size to 480x480 pixels.
Turn off the camera light. Set the camera position to 1 unit
in the Y (vertical) axis. Set its rotation to 90º as shown. 
Figure 2. Change the samples to 1. Leave the other options
in their default values.

Create a new material, drag it over the plane to apply it to the plane. In the Material Properties panel, turn specularity all the way down—that is, black (Figure 3).

Figure 3. Set the material's specular to black (= 0).

With the newly created material selected, click on the Nodes tab to access the material nodes. You will see a single node, called "Material." Add six new nodes. You can Control-click on the blue-gray background in the Nodes window to access the Add Nodes pop-up menu. Add three Image nodes, two Multiply nodes (MathMultiply,) and a Gradient node. Place them in the positions shown in Figure 4. Click on each of the three Image nodes and load a texture in each of them. Use the settings shown in figures 5 to 7.

Figure 4. These are all the nodes we'll be using for in this tutorial.
Figure 5. Notice the scale and the fact that
the image is tiled. Set the Mix color and
Background color to white.
Figure 6. Notice the Position and Scale
settings. Again, make sure that Mix color
and Background color are set to white.
Figure 7. Change the scale to 0.5 and change the
Mix and Background color to white. 
Connect the Color output slot on the wood plank texture into one of the Multiply nodes' A input slot. Connect the Leaking texture's Color output slot into the Gradient's Position input slot. Click on the Gradient texture and change its setting to those shown in Figure 8. Connect the Color output slot on the Gradient node into the B input slot on the Multiply node. As you can see on figure 10, the Multiply node shown here does not have a preview. In order to get a preview of the result, click on the little circle next to the Color output in the Multiply node (Figure 9.) After all this, you should have something like in Figure 10.


Figure 8. Move the white slider to the left. This forces the midtones and
light colors of  the texture into a white.


 Figure 9. This is the preview after clicking on the
small output circle.
Figure 10. Half of the texture is setup. 
Connect the red sign texture's Color output into the B slot of the second Multiply node. Connect the Vector output of this Multiply node into the Diffuse slot of the Material node. Connect the wood plank texture node's Value output into the Bumpmap slot on the Material node. You should have something similar to Figure 11.

Figure 11.
 Hit Command-R to render the scene. You're done. Please feel free to experiment, and if you get any interesting results or suggestions, make sure to pass them on.




These are the textures I used. They come from CGTextures.

1 comment:

  1. Oh, my dear, what a great and interesting tutorial! Thank you so much! I like to learn something new. I like to create new free vector textures and share them with other!

    ReplyDelete