Bookshelf Contents Previous Next Glossary Index Search

Lesson 10: Shader Basics

After modeling a scene you can apply attributes such as color, texture, transparency and reflectivity to objects to achieve photorealistic results. These attributes are created using shaders to create realistic looking materials to assign to objects.

Shaders are kept in the Multi-lister, an important window that displays shaders, lights or forces, or all of these at the same time. The Shader mode of the Multi-lister is used in this lesson as you begin working with shaders and their various parameters.

In this lesson, you create shaders for all parts of a fruitbowl model and assign these shaders to the objects. At the end, you quick render the scene to see a test of the results.

Note: In lessons 10 through 13 you will continue working on this model to add more sophisticated shaders, lighting and some animation.

Initial setup

A file has already been prepared containing the fruitbowl model. Start by opening it and performing a quick render.

Clear the workspace and retrieve a wire file

  1. From the Alias File menu, select Open.
  2. In the File Browser, click the Show List button.
  3. In the CourseWare project folder in the File Lister, double-click the L10_Fruit1 icon to retrieve the wire file. If a confirm box is displayed, click YES to delete all objects, shaders, views and actions.

    Four windows are displayed. Each window shows a bowl on a tabletop containing an apple, a banana, and an orange.

    QuickRender the scene

  4. Click in the Perspective window to make it active.
  5. Select Quick render from the Alias Render menu. All the objects are rendered in blue to show that they are using the Alias default shader.

  6. Click anywhere in the QuickRender window to close it.

Creating and assigning a new shader

Next you create a shader for the apple.

Open the Multi-lister

  1. From the Windows menu, select
    Multi-lister
    Shaders. The
    Multi-lister displays the default Environment and Shader icons. The menus at the bottom contain relevant shader functions.

    Make a new shader

  2. Select New Shader from the Edit menu in the Multi-lister. New shaders are copies of the default shader.

    Tip: You can delete any shader, except the DefaultShader and Environment shader, by clicking on it to make it active, and then selecting Delete Active from the Multi-lister menu.

    Rename the new shader

  3. Double-click on the default shader's name and press the Esc key to clear the existing text.
  4. Type Apple and press Enter.

    Note: Both mixed case and lower case names are used for shaders in this series of lessons.

    Pick the apple object

    In this lesson, the objects have already been named and can be picked by name.

    Tip: You can also name objects using the Information window (Windows Information Information window).

  5. Make sure the Apple shader icon has a white border to indicate that it is the only active shader.
  6. Select Pick Object from the Tool Palette and type apple in lowercase at the prompt line.
  7. Press Enter to pick the apple.

    Assign the shader to the object

  8. With both the Apple shader icon and apple object active, select
    Shading Assign Shader from the Multi-lister menu to assign the shader to the apple.

    Note: You can also create shaders and not assign them to objects. However, only assigned shaders are displayed when you render the scene.

Editing shader parameters

You can edit some of the shader parameters to create the look you want using the Shader and Color editors.

Open the shader editor

  1. Double-click the Apple shader icon to open the Shader editor.

    Tip: You can also open the shader editor by selecting Edit Edit from the
    Multi-lister menu.

    Edit the shading model and shader color

  2. Select the PHONG shader from the Shading Model pop-up menu at the top of the Shader editor.

    This gives the Apple shader icon a shiny, reflective appearance, and displays parameters such as specularity, shinyness and reflectivity in the editor.

  3. In the Common Shader Parameters section, click once on the blue color sample next to the Color parameter to open the Color editor.

    Tip: You can also open the Color editor by selecting Edit color from the Multi-lister menu.

  4. In the Color editor, drag the R slider to 255, and the G and B sliders to 0. This changes the Red, Green and Blue values to define a new red color.

Notice that the Apple shader icon in the
Multi-lister has turned red. In another lesson, you will make this shader even more realistic by adding a texture map.

Keep the two editors open while you proceed.

Copying a shader

To create a shader for the orange, you can copy the apple shader. This lets you create the orange shader more quickly.

Copy and rename the Apple shader

  1. With the Apple shader active, select Edit Copy from the Multi-lister menu. This creates a copy of the Apple shader.
  2. Double-click on the name Apple#2, press the Esc key to clear the name, then type Orange to rename it.

    Assign the Orange shader

  3. With Nothing picked, select
    Pick Object from the Tool Palette and type orange when prompted.
  4. With both the Orange shader and orange object active, select
    Shading Assign Shader to assign the shader to the orange.

    Edit the shader's reflectivity and shinyness

  5. Leave the Orange shader's Shading Model at PHONG.
  6. Double-click on the Shinyness value in the Shader Editor and change it to 5 to make it less shiny than the apple.
  7. Oranges are not as reflective as apples, so change the Reflectivity value to 0.1.

    Edit the shader's color

  8. In the Color Editor, click on the value next to G and type 150 to change the color to orange.

Note: In another lesson, you'll make this shader bumpy by adding a texture map.

Use the arrows to choose the different shaders

Editors always contain the most current parameters set for an active shader. The Shader and Color editors now contain the parameters for the Orange shader.

Tip: To move from one shader to another, click on the left and right arrows on the Shader editor's title bar. However, if you have many shaders, you may find it easier to select the shader icon in the Multi-lister.

Copying shader parameters

Next, you create a shader for the banana and copy some parameters from the Orange shader.

Create and name a new shader

  1. Select Pick Nothing from the Tool Palette to de-select active objects or geometry.
  2. Select Edit New Shader from the Multi-lister menu.
  3. Double click on Shader#2 and press the Esc key to clear the name. Type Banana. Notice that the icon moves in the Multi-lister so all shaders are listed alphabetically.

    Edit the shader's color and assign the shader

  4. In the Color Editor, change the RGB values to 255, 215, and 70 to make the shader yellow. In a later lesson, you edit this shader to create a label for the banana.
  5. Select Pick Object from the Tool Palette, type banana and press Enter to pick the banana.
  6. Select Shading Assign Shader from the Multi-lister menu to assign the new shader to the banana.

    Change the shading model of the Banana shader

  7. In the Shader editor, change the shading model to PHONG. By doing this, you can copy the reflectivity and shinyness values from the Orange shader.

    Copy the desired shader parameters

  8. In the Multi-lister, click the Orange shader icon to select it.
  9. In the Shader editor, press the Shift key and click on the names Shinyness and Reflectivity. The background color behind the names changes to gray.

  10. With the Shift key still pressed, click on the Banana shader in the Multi-lister. It is highlighted in gray.

  11. Now select Edit Copy Parameters from the Multi-lister menu to copy the selected parameters to the banana. Click on the Banana shader to confirm the copy.
  12. Press the Shift key and click on Shinyness and Reflectivity in the Shader editor to de-select them.

    Close the Shader and Color editors

Click the close box icon in the top left corner of both editors to close them.

Editing a shader from the Multi-lister

Next, you copy the apple shader to create a new shader for the tabletop and then edit the various attributes of the shader icon.

Create and rename a new shader

  1. Select Pick Nothing from the Tool Palette to de-select active geometry, then click on the Apple shader in the Multi-lister to select it.
  2. Select Edit Copy from the
    Multi-lister menu to copy it.
  3. Double-click on the name Apple#2, press the Esc key, type Table and press Enter.

    Edit the shader's color

    Pressing the Alt key while you click on areas of the shader ball opens the Color editors for the different parts of the shader without having to open the Shader editor.

  4. Press the Alt key and click on the shader ball where the red is darkest (but not in the shadow area).

  5. The Table shader's Color editor is displayed. The title bar of the Color editor reads Table: Color.
  6. Press the Alt key and click on the white highlight on the shader ball. The Color editor's title bar reads
    Table: Specular.
  7. Press the Alt key and click on the shadow area of the shader ball. The Color editor's title bar reads
    Table: Incandescence.
  8. Press the Alt key and click on the red area to return the Color editor's title bar name to Table: Color.
  9. Change the R value of the shader to 0 and the G value to 51 to create a dark green color.

    Tip: You can also click-drag on the highlight to interactively change the highlight size.

    Assign the shader

  10. Select Pick Object from the Tool Palette and type table to make the table object active.
  11. Select Shading Assign Shader in the Multi-lister to assign the shader to the table.

Importing a transparent shader

You can import and work with shaders created for other projects. This means you can create a library of shaders that can be re-used as needed. A glass shader has already been created, which you can apply to the bowl.

Importing an existing shader

  1. Select File Shader Browse from the Multi-lister menu to access the shader directory.
  2. In the File Lister, click on the Bowl shader icon, then click the Load Shader button in the File Browser. The Bowl shader is displayed in the Multi-lister.

    You'll add a texture map to this glass shader in a later workshop.

    Tip: Alias comes with many predefined shaders that can be found on the 3DCD. You can use these shaders in your own work to quickly render photorealistic images. You should take a few minutes after this lesson to examine some of the 3DCD shaders and look at how they were made.

    Assign the shader to the bowl

  3. Select Pick Nothing from the Tool Palette, then select Pick Object and type bowl at the prompt line to pick the bowl in the scene.
  4. Select Shading Assign Shader to assign the Bowl shader to the bowl geometry.

    Adjust the size and position of the Multi-lister

  5. Select Pick Nothing from the Tool Palette.

There are now seven shader icons in the
Multi-lister: Environment, Shader, Apple, Banana, Bowl, Orange and Table.

If there are more shaders listed than you can see, use the scroll bar at the left of the Multi-lister window, or resize the window by dragging at the corners.

You can also change the icon display to list by name or by a smaller icon. To change the display mode, click on any of the three small buttons on the Multi-lister title bar (text, small sphere, larger sphere).

To see the objects and surfaces an active shader is assigned to, select Shading List Objects....

Try clicking on some shaders to make them active, and notice how the object list changes.

Editing the Environment shader

Now that the shaders are set up for all the objects, you can create the scene's background using the Environment shader. The Environment shader lets you assign a color or a pix file to the scene background, as well as other 3D environment effects such as fog and textures.

Open the Environment editor

  1. In the Multi-lister, double-click the Environment shader icon. The Environment editor is displayed.

    Edit the Environment's color

  2. Click once on the color sample next to Color in the Background section.
  3. In the Color editor, use the RGB or HSV sliders to define a new background color.

    Notice that the Environment icon in the
    Multi-lister automatically displays the color you choose.

    Minimize the Shader and Color editors

  4. Click the Minimize button in the title bar of the editors.

This turns the Environment and Color editors into icons that you can move into a convenient place on your screen.

To reopen the editor, click the icon.

Quick Rendering

In this section, you can use QuickRender to evaluate the scene with the new shaders.

Note: While a quick render shows a preview of the rendered scene, subtle qualities, such as reflectivity and shinyness, are not displayed. To evaluate these qualities, you must perform a full rendering.

QuickRender the scene in the Perspective view

  1. Click in the Perspective view to make it active. The active window determines the initial quick rendered view.
  2. From the Render menu, select
    Quick render. A new QuickRender window is displayed on top of the Perspective view.

  3. Click anywhere in the QuickRender window to close it.

    QuickRender with different render options

  4. From the Render menu, select
    Quick render - to open the
    Global Quick Rendering Parameters window.
  5. Click the Background toggle to display the background color instead of the ground grid, and click the Turbo Assist toggle to render the transparency of the bowl.

    Note: Turbo Assist uses the hardware rendering, which offers faster rendering and transparency. Some features won't display, and the lighting of the scene will be different from a normal QuickRender.

  6. Click the Go button. The following is displayed:

  7. Click anywhere in the QuickRender window to close it.

    Display the scene's lights in the Multi-lister

When you QuickRender a scene without defining lights, default lighting is added automatically. You edit the scene's lighting in Lesson 11.

To see these lights, select List Lights from the Multi-Lister menu. Two icons displaying a directional light and an ambient light are displayed.

More QuickRender options

QuickRender has a complete set of options. For example, you can keep the QuickRender on the screen and render only a part of it.

QuickRender the scene with Persistence toggled on

  1. From the Render menu, select
    Quick render to QuickRender the scene again.
  2. Click the Options button located on the QuickRender window's title bar to display the pop-up menu and select Tgl Persistence.

  3. When Tgl Persistence is checked, the QuickRender window does not disappear at the next mouse click, but re-renders the scene with the new conditions. To de-select a checked option, click the window again.

    QuickRender the Right window

  4. Open the Options pop-up menu again and select Lock Source Window to turn this option off.
  5. Click in the Right window to make it active and click again in the QuickRender window. The rendered scene is updated using the Right window as its source.

    Note: QuickRender always renders in the active window, unless Lock Source Window is checked on in the Options menu. For example, if Lock Source Window had been checked when the Perspective window was active, the Perspective view would always be quick rendered, no matter which window view was subsequently selected.

    Move the QuickRender window

  6. Move the QuickRender window down slightly to show the Perspective window underneath.
  7. Click in the Perspective window to make it active again. When you click next in the QuickRender window, the image is in the Perspective view.

    Tip: A handy way to QuickRender only a portion of a scene is to use a bounding box. Drag the cursor diagonally in the QuickRender window to create a box around the view area. That area quick renders and displays a bounding box around the re-rendered area.

This is useful when you have changed an object's shader and you only want to re-render the area containing that object.

To return to regular QuickRender mode, click outside the bounding box.

Close the QuickRender window and Multi-lister

To close the QuickRender and Multi-lister windows, click the close box in each window's title bar. You may have to maximize the Shader and Color editors to close them.

Save the model

From the File menu, select Save as to save this file in your CourseWare project. Name it myfruitbowl2 so you can use it in the next lesson.

Conclusion

In this lesson you have learned how to:

In the upcoming lessons you'll add texture maps and lighting effects to this fruitbowl.



Bookshelf Contents Previous Next Glossary Index Search

[email protected]
Copyright © 1998, Alias|Wavefront, a division of Silicon Graphics Limited. All rights reserved.