Caffeine Abuse - The Blog

2.5D Shading

It’s kind of funny to see that the world of 3D hasn’t been spared from trends and the desire to dress in whatever that happens to be the latest fashion at the time. Though we might not have an official spring collection coming out each year nor the fancy vernissage held by the design houses from the cloth industry, we still have vogue in some manner. As they should, the trends do have shifted quite a bit during the past decade. Though I still have occasional nightmares every now and then from the time when people for absolutely no obvious reason persisted on putting lens flares on every single image they created, I must say that today’s obligatory flock of birds aren’t by far that painful as they still leave room for some peace of mind (and the ability to actually se other parts of the image).

The trends don’t end there though. It doesn’t seem that long ago most people where crying for photo-realism in their renderer, which at that time was so much harder to achieve than it is today with the more mature soft- and hardware available. Now when realism is more or less within the grasp of everyone it’s nice to see people talking a step backwards, crying for something completely different. A vogue that’s been popular for some time now, is non photorealistic rendering (NPR) and alike. The ability to create and animate everything in 3D and render it in whatever style needed is not only favorable artistically but also a huge timesaver in comparison to traditional hand drawn animation.

Though you might only need two and a half dimensions to give your image just the right touch, you still have to create all three of them. It’s valuable to think about how you want your final image to look before you start modeling. It might sound kind of obvious that the way you object will be perceived is not only due to the shader or color you are using but also the character of the shape (this is especially true if you are to use toon shading). If we for example where to use our material in a technical illustration or animation with mainly flat areas and lots of small details it might not only look out of place but could actually fail to produce the desired look. Since we want to add a cartoon feeling to the set, it’s important that our geometry express this as well. In the cartoon world it seems to be very troublesome to get hold of completely flat or straight objects. Therefore most things found in there have a tendency to be kind of soft or bulgy, even if it would make them erroneous in our world. This is easily accomplished in XSI by a generous use of subdivisions. This ensures that the entire scene is kept as snugly and comfortably as we need it to be.

There’s no reason why we should end it there. Being so close to taking coziness to a whole new level we might as well give it shot. When setting up the color scheme for your scene, try to make use of as vivid colors as possible. You don’t have to limit the selection to warm colors exclusively, since coloring part of the image with any shade from the cool half of color wheel will only add to the richness of the scene. With our color scheme all set we just need to come up with a method that will get the shading across the surface just smooth enough to add the half dimension to a flat 2D drawing. Once done with the solution you are about to familiarize yourself with, it will appear as the easiest thing; the only tricky part is probably figuring out that it’s there. The core of our material is in fact nothing more than a Gradient node. It is however important that you use the right gradient node. We’re not going to use the one found under Nodes>Texture in the Render Tree, but the one under Node>Texture Generators. What’s the difference then? Well, the difference related to this scenario is the ability to use an Incidence node to drive the mapping of the gradient. This enables us to control the gradient depending on the surface’s angle to the camera instead of fiddle around with texture projections.

The project files used in this tutorial can be found at:

0.5 dimensions Step by step

What could possibly be better at this time of the year then a model of flower to really get your material to flourish? Most likely nothing, so start by loading the scene called flower, found on this issues cover CD. This scene contains nine spheres of which eight of them have been modified (by using the Proportional Modeling tool) to form the petals. To create the stalk we’ve deformed a cylinder along a curve.

Select all of the petals, press Ctrl + G to group them and apply a Lambert shader to the group. Open the Render Tree and get a Gradient node from the Node>Texture Generators. Connect it to the ambient and diffuse input of the Lambert node. Open the properties of the Gradient node. By default there’s quite a lot of color markers controlling the gradient but we only need two of them so delete the rest.

Select one of the markers, move it all the way to the left side of bar and give it a clear yellow color. Now select the other marker, move all the way to the right and set the color to a vibrant orange. The markers position and color are by now way fixed, so feel free to use your favorite colors instead. Just make sure there’s clear difference between them. Next switch to the input tab and change the Input Type to Scalar input.

Now, get an Incidence node (Nodes>Illumination), set the Bias to 0,15, the Gain to 0,75 and connect it to the input on the Gradient node. If you draw a render region you can see how the flower is being shaded by the gradient. To make the flower even more vibrant connect the output of the Gradient to the Incandescence of the Lambert node. Under the Indirect Illumination on the Lambert node set the Incandescence Intensity to about 0,2.

Open your Cameras Property Editor, switch to the Lens Shaders tab and apply a Toon Ink Lens shader. Press the Inspect button to bring up its properties. The flower now has an ink line applied to it, but with a constant thickness along all the objects it might be a bit lifeless. So, under Taper tab set the Anisotropy Amount to 1. This will shift the thickness depending on its angel to the camera.

Let’s move on to the next tab, labeled Variation. Set the Spread Amount 0,6 Under Variation change the Min to 0,5. This will add even further variations to the ink, making it appear more natural. Increase the Frequency sliders for additional variations. Leave the rest as it is or preferable, continue trying out different parameters and setting on your own until your pleased with the result.
A Couple of additional tips
Half dimensions, rendering settings and fuzziness, all nicely wrapped up with these expert tips.

Tip # 01
Still feel that something is missing? Well, a subtle bumpmap will break up the uniformity of the color, giving it an almost fuzzy look, which might be just what you need for that final touch. Add a fractal node (or alike) or use the image found in the Pictures folder on the cover CD.

Tip # 02
A little too much depth in your image? Depending on what style you are trying to give your rendering you might actually benefit (or make do) without the Lambert shader in your material. By connecting the output of the Gradient node directly to the Surface input of your Material you will reduce some of the depth in your image, giving it more of 2 dimensional feeling. Another plus from getting rid of the Lambert node is that your materials aren’t depending on the lights for their shading anymore, and without the need of lights the rendering time is bound to go down.

Tip # 03
Whenever working with the toon ink lens shader one must unfortunately be prepared to take a hit on the rendering time. To optimize your rendering and avoiding the risk of flickering when your animation is played back, you should tweak the settings in the Render Property Editor as well as those found under the Sampling tab in the Toon Ink Lens Property Editor. Though the last of these is supposed to be enough to control the sampling of the ink, one should fiddle with both of them to find the best settings for a particular scene. The thicker and complex your ink is the more sample will be needed to maintain the quality. As always you should keep these settings rather low to speed up the previews, then increasing them when it’s time for the final render.

Tip # 04
Another way to approach the 2.5D type of rendering would be to combine two or more versions of the same scene, which are rendered with different materials. To withhold simplicity for controlling your entire scene you set up the materials within the same scene by using different pass’s and partitions. Use a Constant or Toon shader (or why not try the material created above) as the base for the effect. Create another pass, but use FG/GI to illuminate the scene. Bringing the rendered versions of the passes into the FX Tree and blending them together (either with or without additional filters) can produce some truly interesting images.