Rendering Adds Realism1 Mar, 2002 By: Bill Fane
Last time (January 2002), we used AutoCAD's standard visualization functions to go from a basic wire frame through a simple hidden-line removal (figure 1) and on to the shaded image of figure 2. This month, we'll dabble with AutoCAD's rendering operations to see how easy it can be to produce a photorealistic image such as figure 3. No, figure 3 is not the same object as figures 1 and 2. Rendering is good, but not that good.
You light up my life
Figure 4 shows a glass of wine sitting on a table, displayed with Shademode set to Gouraud. If you want to follow along, this drawing is available at www.cadalyst.com/solutions/ lc/0302lc/0302lc.dwg.
All light is provided by ambient light, along with a single fixed light coming from over your left shoulder. Ambient light is the kind of soft, shadowless light that you get on a cloudy day. The brightness of objects or parts of objects is determined solely by the angle between your viewpoint and the fixed light. This lighting, though not too spectacular, is adequate for many objects.
To get really impressive visualizations, however, you need to explore the rendering functions in AutoCAD.
Select View | Render | Light to bring up the dialog box in figure 5. Here you control the brightness of the ambient light and add specific light sources. Let's add a new light.
First, make sure the box beside the New button shows Point Light, then click on the New button. This brings up another dialog box (figure 6), in which you define the light.
Your light needs a name with a maximum length of eight characters. While you are here, turn on the Shadows box. Now go to the Position area and click the Modify button.
The dialog box collapses, and AutoCAD asks you to specify a position in the drawing for the light. You can use any normal AutoCAD method, such as typing in a point triplet, or you can use object snaps. For our sample drawing, the origin is at the left front corner of the table, so I placed the light at 100,-20,40.
When you finish the operation, AutoCAD places a small block with an attached attribute in the drawing. If you want to move the light later, you can use standard AutoCAD Move operations. Note that the coordinates of a light when you create it, or later if you modify it, are based on the UCS that is current at the time of creation or modification.
Once you place the light, the previous dialog box returns. Select OK to return to the Lights dialog box, then click OK again to return to the drawing.
The first thing you notice is that nothing has changed. If you set Shademode to Gouraud, your image still looks like figure 5. To see the effect of adding the light, you must use the Render command.
Click on View | Render | Render to bring up the dialog box in figure
7. Make sure you select the following options:
- Rendering Type: select Photo Real from the scroll list.
- In the Rendering Options area, turn on Smooth Shade and Shadows.
- Click on Background. In the dialog box that appears, turn off AutoCAD Background and turn on Solid. Now set all three primary colors to 1.0, then click OK.
- Click Render, and after a short pause the screen looks like figure 8. Note that anything that changes the screen view, such as scrolling with the mouse wheel or slider bars, redraws the screen, which makes your rendering disappear. I'll tell you later how to save your rendering.
The shadow knows
Keep in mind these significant points about lights, shadows, and rendering.
First, as noted earlier, when you create a light, you must tell it that it is capable of casting shadows. In addition, in the Render dialog box you must turn the Shadows option on and set the render type to Photo Real or Photo Raytrace.
Next, you often need to increase the Ambient light in the Render dialog box. The default intensity for individual lights is so high that it often swamps the ambient.
You can create three types of lights in AutoCAD. We have already used a Point light. This radiates light outward in all directions, like a light bulb.
You can also create a Spotlight, which projects a cone of light. You can specify the cone angle for the central hot spot and for the falloff zone around the hot spot.
The final light type is a Distant light. This is a light that is so far away (say 93,000,000 miles) that its light rays are effectively parallel. The real fun with this light is that it offers Sun Angle options. It is used mainly in architectural applications. You specify the location of your building either by latitude and longitude or by city name. You can then vary the date and time to see how shadows change during the year. You may want to be careful using the city name option, however. I am aware of at least two hiccups in the listit doesn't include Vancouver, BC, Canada, and it locates Victoria, BC, Canada, about 300 miles too far south.
Placement of lights is more of an art than a science. A good starting point is to use the method that portrait photographers use. They usually start with a brighter light higher and behind the camera so it shines over one of their shoulders. A second, dimmer light is placed lower and to the other side, but still behind the camera, so it fills in and softens the shadows.
I'm a material guy
The next major step in realistic renderings is the application of materials.
Click on View | Render | Materials to bring up the dialog box in figure 9. Click on the Materials Library button near the center to bring up the dialog box in figure 10. Material definitions reside in an external file, and just like linetype definitions, you have to specifically import the ones you want to use. Scroll down the list until you find Glass. Select it, then select <-Import. Click OK to return to the Materials dialog box (figure 9).
In the Materials dialog box, make sure Glass is highlighted, then select Apply. The box collapses, and you are invited to select one or more objects. Select the wine glass, then press <Enter>. When the dialog box returns, click OK.
Now, run View | Render | Render again. Make sure the Materials option is turned on, then select Render. Magic! As figure 11 shows, the glass is now transparent. Repeat these steps to apply WoodMed. Ash to the table.
While you are in the Materials dialog box, select New to create a new
material called WineRed. The left side of this dialog box lets you
select an attribute to define, and the definition for each attribute is
set in the center section of the dialog box. Use the following settings:
- Color/Pattern value 1, turn off By ACI, and set Red to 1.0
- Roughness 0.5
- Transparency 0.5
- Refraction 1.0
Select OK, then attach this material to the wine. Now run Render, but this time change the Render Type to Photo Raytrace.
The rendering takes somewhat longer, but eventually produces the image in figure 3.
Notice how the wood grain correctly differentiates between face and edge/end grain and the glass and the wine cause proper reflections and refractions. Just for fun, render again using Photo Real. Note the differences in time and appearance.
So now that you have your rendering just right, how do you save it? There are several ways to capture screen images, but the easiest is to click on Tools | Display Image | Save to start the SaveImg command. Choose a file format, then select OK. You are next asked for a filename. I usually use Caesar, because I like to
Render unto Caesar
You can use this method to capture any screen shot in AutoCAD, not just a rendering.
This brief introduction to some of AutoCAD's visualization features should whet your appetite to do more exploring and experimenting.
And now for something completely different
When two full moons fall in the same calendar month, the second one is called a blue moon because old calendars colored it blue to differentiate it from the first one. This happens about once every 16 months.
Halloween 2001 was a blue moon on the west coast of North America for the first time in 46 years, and it won't happen again until 2020. Because of time zone differences, Halloween was not a full moon on the east coast.
Twice in a blue moon. Coincidentially with the blue moon on October
31, Captain LearnCurve and his lovely wife became grandparents again.
Two-year-old Rebecca has a baby brother, Bryan Robert Milne, 7 pounds,
15 ounces, and another baby brother, Brodie Kenneth Milne, 7 pounds, 6
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor and Autodesk Technical Evangelist Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD video tips. Subscribe to the free Cadalyst Video Picks newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!