Lighting Filters Primitives

Two primitives, Diffuse Lighting and Specular Lighting, are included to simulate light shining on objects. They represent two of the three parts of the Phong reflection model for modeling light in computer graphics. The three parts of the model are:

Phong Model.
An illustration of the components of the Phong model. From left to right: ambient light, diffuse light, specular light. All light sources combined. The diffuse and specular light source is the same, a red distant light coming from the upper left. The specular image has had a black background added to set off the specular light.

The Phong model does not take into account shadows that would be caused by one area of an object on another, that is it does not do ray tracing.

The contour of an object in the z (out of the drawing) direction is described by a bump map that is defined by the Alpha channel of an object. The values of the pixel and the neighboring pixels in the bump map define the normal to the surface for the pixel.

The two lighting filters share in common most of their attributes such as the type of light source, its color, and its position; thus we'll discuss them together.

When applying a lighting filter with a large Surface Scale, the limited resolution of the bump map may create artifacts. These can be removed by applying a small amount of Gaussian blur to the image.

Large Sphere.
The limited resolution of the bump map has resulted in artifacts on the sphere on the left. A small amount of blurring has removed the artifacts on the sphere on the right (the sphere has also been clipped).

Distant Light Source

This light source simulates a light at a large (infinite) distance from the illuminated object. The required attributes are:

  • Azimuth: The direction (angle) of the light source in the drawing plane. The angle is defined in degrees from the horizontal (x) axis in the clockwise direction. Note that this does not match either angle definition used by Inkscape (see the section called “Transformations”). Recall that SVG uses a left-handed coordinate system where the positive y direction is down.
  • Elevation: The direction (angle) of the light source above the drawing plane (in degrees).
Distant Light.
Five spheres illuminated by Distant Light sources. The light from the left is a Specular reflection, while that on the right is a Diffuse reflection.

Point Light Source

This light source simulates a point light source near an illuminated object. One triple set of numbers (x, y, z) is required to set the Location of the light. The units are in the coordinate system of the lit object. Note: z represents the distance out of the plane (toward the viewer of the SVG drawing) if x or y are not inverted.

Distant Light.
Five spheres illuminated by Point Light sources. The light from the left is a Specular reflection while that on the right is a Diffuse reflection. The small red and blue circles indicate the positions of the light sources.

Spot Light Source

This light source simulates a point light source near an illuminated object but with a limited cone of light. One triple set of numbers (x, y, z) is required to set the Location of the light and another to set the direction the center of the cone points (Points At). See previous section for the definition of the coordinate system. The Specular Exponent sets how well-focused is the light; the higher the value, the more sharply focused the light. The Cone Angle (degrees) defines the maximum angle for the light. The lights are directed at each other.

Spot Light.
Five spheres illuminated by Spot Light sources. The light from the left is a Specular reflection, while that on the right is a Diffuse reflection. The small red and blue circles indicate the positions of the light sources. The cone angle is 25°.