Creating Gradients

 
 
 

You can use gradients to create a number of different shading effects. Besides using them to texture objects, you can use gradients to drive other shaders' parameters. For example, gradients are commonly used to blend two textures together.

The Gradient Shaders

You can add gradients to your scene objects using the Gradient texture shader which provides you with a gradient control to set separate color and alpha gradients. You can create gradients of up to eight colors or alpha values.

  • The gradient texture shader applies a gradient texture to the surface of the selected object(s).

    In this example, the head was textured using the gradient texture shader. A standard vertical gradient, set to the Spectrum preset, shades the head's surface.

  • The 2D gradient shader accepts a scalar or vector input that drives the color gradient that it outputs. This allows you to create gradients based on, for example, distance, vector coordinates, or in the case of the image shown below, incidence.

    In this example, the head was textured using the 2D gradient shader whose gradient is controlled by an incidence shader. The incidence determines where the gradient colors are placed.

Connecting Gradient Shaders

To connect a gradient texture or mixer shader to an object, use one of the texturing methods described in Applying a Texture.

Once the gradient shader is applied, open its property editor and define the gradient using the gradient controls as described in the following section.

Using the Gradient Controls to Define a Gradient

The gradient slider, in the Gradient texture or mixer shader's property editor, is where you create and adjust the gradient. It displays the gradient left-to-right from beginning (position 0.00) to end (position 1.00). By default, a new gradient shader displays a six-marker multi color RGBA gradient (on the RGBA Gradient tab) and a two-marker black-to-white alpha gradient (on the Alpha Gradient tab).

Although the following procedures explain how to define an RGBA gradient on the RGBA Gradient tab, the process for defining an alpha gradient on the Alpha Gradient tab is nearly identical. Defining an alpha gradient is described in Activating the Alpha Gradient.

TipYou can start out by setting the gradient to one of the available presets by clicking the corresponding Preset button in the property editor. Presets are available for both the RGBA and alpha gradients.

Gradient Controls

 

 

A

Color Markers

  • Click a color marker to display its color and position.

  • Move the marker to adjust the color's position in the gradient.

See Adding Color Markers to the Gradient and Adjusting Color Marker Positions on the Gradient.

B

Interpolation Markers

  • Click interpolation markers to display their positions.

  • Move them to control the midpoint between the two adjacent colors.

See Adjusting the Blend Between Two Markers.

C

Gradient Slider

The gradient slider shows how gradient colors are blended together.

D

Color Sliders

Use the sliders to adjust the selected color marker's color. See Defining Color Properties [Commands and Tools].

E

Linear/Cubic Interpolation button

Click this button to switch between linear and cubic interpolation. See Changing the Gradient's Interpolation.

F

Gradient Type drop-down list

Click the arrow to select a gradient type from the list. See Selecting a Gradient Type.

G

Invert Direction checkbox

Click here to invert the gradient's direction. See Inverting a Gradient.

H

Clip checkbox

Click here to clip the gradient so that the end colors are not displayed outside their active ranges. See Clipping a Gradient.

I

Gradient Slider (with dotted highlight)

Shows the gradient with a display-only gamma correction.

  • Right-click anywhere on the gradient slider to open its pop-up menu where you can toggle (on and off) the Gamma Correction displayed for all color widgets on the property page.

Note that switching the gamma correction off for a particular color widget is only turning it off locally for this widget. The global preference setting remains as is.

See Display Preferences [Preference Reference] for how to set the color correction options.

J

Color Chip (with dotted highlight)

Shows the color with a display-only gamma correction.

  • Right-click on the color chip to toggle (on and off) the Gamma Correction displayed for all color widgets on the property page.

Note that switching the gamma correction off for a particular color widget is only turning it off locally for this widget. The global preference setting remains as is.

See Display Preferences [Preference Reference] for how to set the color correction options.

Adding Color Markers to the Gradient

  • Click anywhere on the gradient slider to add a new color marker. By default, the marker assumes the gradient's color at the click-point. You can have up to eight markers on a gradient.

    When you add a color marker, interpolation markers are automatically inserted at the midpoint between the new marker and adjacent markers.

Editing Markers' RGBA Values

  1. Click any marker to select it.

  2. Use the Color sliders (or other color controls) to adjust its color.

    For more information on defining colors, see Defining Color Properties [Commands and Tools].

Adjusting Color Marker Positions on the Gradient

  • Click any color marker to select it and do one of the following:

    • Drag the marker to a new position.

      or

    • Enter a new position value in the Pos text box. Position values can range from 0.0 (the beginning of the gradient) to 1.0 (the end of the gradient).

Adjusting the Blend Between Two Markers

  • Click the round interpolation marker between two color or alpha markers to select it and do one of the following:

    • Drag the interpolation marker to a new position.

      or

    • Enter a new position in the Pos text box. Interpolation marker position values can range from 0.05 to 0.95.

Deleting Color Markers From the Gradient

  • Right-click the color marker and choose Delete Marker from the menu.

Changing the Gradient's Interpolation

  • Click the interpolation button (marked Cubic or Linear, depending on the selected interpolation type) to switch between cubic and linear interpolation.

    Cubic interpolation creates smoother transitions between gradient colors, while linear interpolation results in sharper transitions.

Selecting a Gradient Type

  • From the list, select one of the gradients shown below.

A

Gradient used: Spectrum preset

B

Vertical: Creates a standard linear gradient that starts from the bottom of the texture projection object and gradiates to the top.

C

Horizontal: Creates a standard linear gradient that starts from the leftmost edge of the texture projection object and gradiates to the rightmost.

D

Radial Wave: Creates a gradient that begins at the center of the texture projection and gradiates outward, in a bull's-eye pattern.

E

Radial Rainbow: Creates a rainbow-like gradient that originates at the center of the texture projection, except this mode uses a linear, symmetrical pattern.

F

Diagonal Down: Creates a standard linear gradient that starts from the bottom-left corner of the texture projection object and gradiates to the top-right corner.

G

Diagonal Up: Creates a standard linear gradient that starts from the top-left corner of the texture projection object and gradiates to the bottom-right corner.

NoteIf you have the alpha gradient active in the Alpha Gradient tab, changing the gradient type for the RGBA gradient changes it for the alpha gradient as well.

Inverting a Gradient

  • Activate the Invert option to reverse the gradient's direction — a gradient going from top to bottom goes from bottom to top, and so on.

NoteIf you have the alpha gradient active in the Alpha Gradient tab, inverting the RGBA gradient inverts the alpha gradient as well.

Clipping a Gradient

  • Activate the Clip option to prevent the first and last colors in the gradient from appearing outside of their active ranges.

    When this option is active, the gradient color is set to black from the beginning of the gradient to the beginning of the first color's active range and from the end of the last color's active range to the end of the gradient.

    When this option is inactive, the following occurs:

    • The first color in the gradient is applied from the beginning of the gradient to the beginning of the first color's active range.

    • The last color in the gradient is applied from the end of its active range to the end of the gradient.

NoteIf you have the alpha gradient active in the Alpha Gradient tab, clipping the RGBA gradient clips the alpha gradient as well.

Activating the Alpha Gradient

In addition to an RGBA gradient, the gradient shaders allow you to create a separate gradient in the alpha channel. This allows you to vary the gradient's alpha independently of its color.

For example, you might use a seven-marker RGBA gradient and a two-marker alpha gradient so that the gradient gradually becomes less transparent overall as it transitions from color to color, as shown in the following illustration:

   

Color gradient: The head is textured with a gradient shader. Only the RGBA gradient is used.

     

Color gradient and Alpha gradient: The same head now has the alpha gradient active, which gradually makes the RGBA gradient more opaque as it nears its end.

NoteActivating the alpha gradient overrides any alpha values that you set for the color markers in the RGBA gradient.

To define an alpha gradient

  1. From the Gradient (texture or mixer) property editor, go to the Alpha Gradient tab and activate the alpha gradient. The default black to white alpha gradient is displayed.

    NoteYou can immediately set the gradient to one of the available presets by clicking the corresponding Preset button.
    • Black and White: a two-marker alpha gradient that goes from black (alpha value 0) to white (alpha value 1).

    • White and Black: a two-marker alpha gradient that goes from white (alpha value 1) to black (alpha value 0).

  2. Use the gradient controls to define the alpha gradient the same way that you would to define a color gradient (described Using the Gradient Controls to Define a Gradient).

The difference is that instead of setting color values using color sliders, you set alpha values for each marker using a single Alpha slider.

A

The gradient slider and other gradient controls work the same way for the alpha gradient as they do for the RGBA gradient.

B

Click here to activate the alpha gradient.

C

Use the alpha slider to set alpha values for the selected alpha marker in the gradient.

The rest of the gradient parameters also work the same way for alpha gradients as they do for RGBA gradients.

NoteThe alpha and RGBA gradients cannot have a different gradient type. Similarly, inverting or clipping the alpha gradient does the same to the RGBA gradient.

Animating Gradient Markers

You can animate color/alpha (square) and interpolation (round) markers, on both RGBA and alpha gradients, to vary their colors/alpha values and positions over time.

You can also animate the positions of interpolation markers. You do this by setting keyframes for any given marker's color, alpha, or position parameters.

As you might imagine, this can quickly become time consuming, which is why the Gradient property editor provides animation tools to key gradient markers for you. The following buttons are available:

Click these buttons to quickly add keyframes to color and interpolation markers or remove animation and attached shaders from markers.

NoteWhen you use the Key All and Remove Keys buttons to set or remove keys, only parameters on the current tab have keys set or removed.

For example, clicking the Key All button from the Alpha Gradient tab will only set keys for the alpha gradient's parameters. To key RGBA gradient parameters as well, click the Key All button on the RGBA Gradient tab.

To animate gradient markers

  1. Go to the frame at which you want to set keys.

  2. From the RGBA Gradient or Alpha Gradient tab, do one of the following:

    • Click the Key All button to key all visible markers in the gradient. Square color/alpha markers' Color/Alpha and Pos values are keyed, and round interpolation markers' Pos values are keyed.

      or

    • Select a square color/alpha marker or a round interpolation marker, and click the Color/Alpha and/or Pos parameter's animation icon.

To remove the animation on the markers

  • From the RGBA Gradient or Alpha Gradient tab, do one of the following at any frame:

    • Click the Remove Keys button to remove all keys from all markers' parameters.

      or

    • Select a color/alpha marker or a round interpolation marker, go to a frame where you've applied a key, and click the Pos parameter's animation icon.

To reset the marker positions and remove keys

  • Click the Reset button.

    This removes all keys on the color, alpha, and interpolation markers, puts all markers back in their original positions, and sets them to their original color, alpha, and interpolation values.

Connecting Shaders to Gradient Markers

You can connect shaders to any of a gradient's color, alpha, or interpolation markers. Color and alpha markers can be connected from the Gradient property editor, while interpolation markers must be connected in the render tree. This allows you to, for example, create a gradient of textures.

To connect a shader to a marker's color/alpha parameter

  1. From the RGBA Gradient or Alpha Gradient tab, click a color/alpha marker to select it.

  2. Do one of the following:

To remove all shaders from color/alpha and interpolation markers

  • From the RGBA Gradient or Alpha Gradient tab, click the Remove Shaders button. Any shaders attached to any of the gradient markers' Color/Alpha and position parameters are disconnected.

NoteClicking the Remove Shaders button from the RGBA Gradient tab only removes shaders connected to the RGBA gradient's parameters.

Clicking the button from the Alpha Gradient tab only removes shaders connected to the alpha gradient's parameters.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License