fbe University of New South Wales Sydney Australia UNSW
Faculty of the Built Environment search

6 - Surfaces and Atmospheric Effects

6.1 Surface Description
6.2 Atmospheric Effects
6.3 The Default Medium
6.4 Surface Specification


Surfaces are used to control the interaction between light sources and objects. A surface specification consists of information about how the light interacts with both the exterior and interior of an object. For non-closed objects, such as polygons, the "interior" of an object is the "other side" of the object's surface relative to the origin of a ray.

Rayshade usually ensures that a primitive's surface normal is pointing towards the origin of the incident ray when performing shading calculations. Exceptions to this rule are transparent primitives, for which rayshade uses the direction of the surface normal to determine if the incident ray is entering or exiting the object. All non-transparent primitives will, in effect, be double-sided.


6.1 Surface Description

A surface definition consists of a number of component keywords, each of which is usually followed by either a single number or a red-green-blue color triple. Each of the values in the color triple are normalized, with zero indicating zero intensity, and one indicating full intensity.

If any surface component is left unspecified, its value defaults to zero, with the exception of the index of refraction, which is assigned the default index of refraction (normally 1.0).

Surface descriptions are used in rayshade to compute the color of a ray that strikes the surface at a point . The normal to the surface at P», N», is also computed.

ambient colorR colorG colorB
Use the given color to approximate those surface-surface interactions (e.g., diffuse interreflection) not modeled by the ray tracing process. A surface's ambient color is always applied to a ray. The color applied is computed by multiplying the ambient color by the intensity of the ambient light source.

If is in shadow with respect to a given light source, that light source makes no contribution to the shading of .

diffuse colorR colorG colorB
Specifies the diffuse color. The diffuse contribution from each non-shadowed light source at is equal to the diffuse color of the surface scaled by the cosine of the angle between and the vector from to the light source.

specular colorR colorG colorB
Specifies the base color of specular reflections.

specpow exponent
Controls the size of the specular highlight. The larger the exponent, the smoother the apparent finish. The intensity of specular highlights from light sources are scaled by the specular color of the surface.

reflect reflectivity
Specifies the specular reflectivity of the surface. If non-zero, reflected rays will be spawned. The intensity of specularly reflected rays will be proportional to the specular color of the surface scaled by the reflectivity.

transp transparency
Specifies the specular transmissivity of the surface. If non-zero, transmitted (refracted) rays will be spawned.

body colorR colorG colorB
Specifies the body color of the object. The body color affects the color of rays that are transmitted through the object.

extinct coefficient
Specifies the extinction coefficient of the interior of the object. The extinction coefficient is raised to a power equal to the distance the transmitted ray travels through the object. The overall intensity of specularly transmitted rays will be proportional to this factor multiplied by the surface's body color multiplied by the transparency of the object.

index N
Specifies the index of refraction. The default value is equal to the index of refraction of the atmosphere surrounding the eye.

translucency translu colorR colorG colorB stexp
Specifies the translucency, diffusely transmitted color, and Phong exponent for transmitted specular highlights. If a light source illuminates a translucent surface from the side opposite that from which a ray approaches, illumination computations are performed, using the given color as the surface's diffuse color, and the given exponent as the Phong highlight exponent. The resulting color is then scaled by the surface's translucency.


6.2 Atmospheric Effects

Any number of atmospheric effects may be associated with the default medium ("air").

fog colorR colorG colorB thinness»
Add exponential fog with the specified thinness and color. Fog is simulated by blending the color of the fog with the color of each ray. The amount of fog color blended into a ray color is an exponential function of the distance from the ray origin to the point of intersection divided by the specified thinness for each color channel. If the distance is equal to thinness, a ray's new color will be half of the fog color plus half its original color.

mist colorR colorG colorB thinness» zero scale
Add global low-altitude mist of the specified color. The color of a ray is modulated by a fog with density that varies linearly with the difference in z coordinate1 between the ray origin and the point of intersection. The thinness values specify the transmissivity of the fog for each color channel. The base altitude of the mist is given by zero, and the apparent height of the mist can be modulated using scale, which scales the difference in altitude used to compute the fog.

fogdeck altitude offset scale» chaos-scale colorR colorG colorB thinness»
Add low-altitude fog, with transmissivity modulated by a chaotic function.


6.3 The Default Medium

The default medium is the medium which surrounds and encompasses all of the objects in the scene; it is the "air" through which eye rays usually travel before hitting an object. The properties of the default medium may be modified through the use of the atmosphere keyword.

atmosphere [N] [atmospheric effects]
If given, N specifies the index of refraction of the default medium. The default is 1.0. Any atmospheric effects listed are applied to rays that are exterior to every object in the scene (e.g., rays emanating from the camera).

    /*
     * Red sphere on a grey plane, with fog.
     */
    eyep 0.  -10.  2.
    atmosphere fog .8 .8 .8 14.  14.  14.
    plane 0 0 0  0 0 1
    sphere  diffuse 0.8 0 0   1.5  0 0 1.5

6.4 Surface Specification

Rayshade provides a number of ways to define surfaces and to bind these surfaces to objects. The most straight-forward method of surface specification is to simply list the surface properties to be used. Alternatively, one may associate a name with a given surface. This name may subsequently be used to refer to that surface.

surface name <Surface Definition>
Associate the given collection of surface attributes with the given name.

The binding of a collection of surface properties to a given object is accomplished in a bottom-up manner; the surface that "closest" in the modeling tree to the primitive being rendered is the one that is used to give the primitive its appearance.

An object that has no surface bound to it is assigned a default surface that give an object the appearance of white plastic.

The most direct way to bind a surface to a primitive is to specify the surface when the primitive is instantiated. This is accomplished by inserting a list of surface attributes or a surface name after the primitive's type keyword and before the actual primitive data.

    /*
     * A red 'mud' colored sphere reseting on a white sphere.
     * To the right is a sphere with default surface attributes.
     */
    surface mud ambient .03 0.  0.  diffuse .7 .3 0.
    sphere  ambient .05 .05 .05 diffuse .7 .7 .7   1.  0 0 0
    sphere mud 1.  0 0 2
    sphere 1.  1.5 0 0
Here, we define a red surface named "mud". We then instantiate a sphere, which has a diffuse white surface bound to it. The next line instantiates a sphere with the defined "mud" surface bound to it. The last line instantiates a sphere with no surface bound to it; it is assigned the default surface by rayshade.

The applysurf keyword may be used to set the default surface characteristics for the aggregate object currently being defined.

applysurf <Surface Specification>
The specified surface is applied to all following instantiated objects that do not have surfaces associated with them. The scope of this keyword is limited to the aggregate currently being defined.

    /*
     * Mirrored ball and cylinder sitting on 'default' plane.
     */
    surface mirror ambient .01 .01 .01 diffuse .05 .05 .05
                   specular .8 .8 .8 specpow 20 reflect 0.95
    plane 0 0 0  0 0 1
    applysurf mirror
    sphere 1  0 0 0
    cylinder 1  3 0 0  3 0 3
For convenience, the name cursurf may be used to refer to the current default surface.

The utility of bottom-up binding of surfaces lies in the fact that one may be as adamant or as non-committal about surface binding as one sees fit when defining objects. For example, one could define a king chess piece consisting of triangles that have no surface bound to them, save for the cross on top, which has a gold-colored surface associated with it. One may then instantiate the king twice, once applying a black surface, and once applying a white surface. The result: a black king and a white king, each adorned with a golden cross.

    surface white ...
    surface black ...
    surface gold ...
    ...
    name cross list
        box x y z  x y z
        ...
    end

    name king list
        triangle x y z  x y z  x y z
        ...
        object gold cross
    end

    object white king translate 1. 0 0
    object black king

Footnotes
1 This all but assumes that the default up vector (0,0,1) is being used. (go back)


Go to the next section Transformations
Go to the Contents