# 8.14.5 Lighting on 3D Graphs

In openGL 3D graphs, it is possible to add lighting effects:

1. Double-click on the layer of the 3D plot to open the Plot Details dialog.
2. Go to the Lighting tab and modify settings.

or

1. Activate an 3D openGL graph.
2. Click the Lighting Control Dialog button in the Style toolbar to open the Lighting Control Dialog.

The lighting effect could be turned on by changing the Lighting Mode to Directional Mode. And its source direction and color could be customized.

## Lighting Mode

Origin supports directional lighting mode.

The directional light is the simplest light, comparing with the spotlight and pointlight. The light rays of directional light are, to all intents and purposes, parallel, just like the light from the Sun. That means any ray approaching an object is always the same at angle. Also, for flat surfaces affected by a directional light, the degree of shading will be the same right across the surface.

## Light Direction

The light source direction is defined by angles in both horizontal and vertical plane.

In the horizontal plane, zero degree means the light source comes from the east toward the west. With the degree increasing from 0 to 360, the light source rotates in a counterclockwise direction. For example, 90 degrees places the light source to the north of the unrotated surface.

In the vertical plane, zero degree places the light source at the horizon and shining horizontally. An angle of 90 degrees places the light source directly overhead and shining down onto the map and -90 degrees means the opposite.

The dynamic light source means that the light source is fixed according to the specified horizontal and vertical direction, and wouldn't rotate with the surface. In opposite,if this check box is unselected, the light source is fixed relative the surface. If the surface is rotated, the light rotates with it.

## Light Color

Our visual perception is based on the reflection and absorption of light. That's why we can see the colorful world. For example, a sky appears blue in our eyes, this is because the atmosphere absorbs all colors in the visible light except blue. Since the blue reflected light is detected by our eyes, we say the sky is blue. To represent the lighting and render the 3D surface, Origin offers three different types of light colors to represent reflection, Ambient, Diffuse and Specular.

Origin uses a pure white light source. As White light is the effect of combining the visible colors of light in suitable proportions, when the white light shines on the surface, some of the light is absorbed based on the color of the surface material at the shone point, and some light is reflected as below three different types of light respectively.

• Ambient
Ambient light is the light that have been multiple scattered by the environment and distributes evenly. The light, the direction of which is undetermined, seems from all directions. The default color is Black, which means the ambient light does no contribution for the surfaces.
• Diffuse
Diffuse light depends only on the angle of the light to the surface. It is brighter if the incident light is vertical to the surface than the incident light come from other oblique angle. The light comes from a particular angle and reflected in all directions. The default Diffuse color is LT Gray, which is a combination effect of color white with 75% intensity.
• Specular
Specular means that light is perfectly reflected in a mirror-like way from the light source to the viewer. The light comes from a single incoming direction and is reflected to a single outgoing direction. Brightening specular light results in strong shadow effects and more apparent bright spots. The default Specular color is White.
• Shininess
Shininess is used to determinate the size of the specular reflections. As the shininess percentage increases, the reflections become more focused, and more similar with the mirror reflection. The range of its value is between 0 and 128.

In order to reflect the surface material color components evenly and objectively, these reflectivity colors should be specified as shades of gray generally. But specifying non-gray colors for the reflectivity can be used to present the special effects. For example, assume the Ambient reflectivity is set to pure red, and the Diffuse and Specular components are set to pure black. The Diffuse and Specular components are essentially disabled by setting their reflectivity color to black. The only light that is reflected to the viewer is red ambient light. Portions of the surface that lack a red component in the material color will appear black, since only red light is reflected to the viewer.

 Notes: By default, lighting is not supported on flatten surfaces, this is controlled by the system variable @OGLFL (default value = 0), but you can set the system variable @OGLFL to 1 to make lighting also supported on flatten surfaces(Run @OGLFL = 1 in command window or script window). This can be turn off later by running @OGLFL = 0, and when you restart Origin, the system variable will change back to the default value 0.