home | << prev | next >> | contents |
A light source illuminates the objects in a scene. Light sources in mental ray are programmable and consist of a light source name, a named light shader function, and an optional origin and direction (at least one of the two must be present), plus various light-specific parameters such as shadowmap and photon information. Starting with mental ray 3.5 a light profile may also be among the light-specific parameters. Light shaders accept shader parameters that depend on the shader.
The lights available in a scene are defined outside materials and typically referenced by name inside materials. Most material shaders have a parameter of type "light array" that allows referencing a list of light instances by name. The material shader then applies the illumination from these lights to the shaded surface. Material shaders also have the option of obtaining a list of all lights in the scene directly from mental ray. Starting with version 3.5 a material shader may also obtain from mental ray a list of lights attached to its associated object instance.
The shading function for light sources may be either a user written function linked at run time, or it may be one of the standard functions. There are standard shader libraries for Alias Maya, Autodesk 3ds max, Dassault Systèmes CATIA, SOFTIMAGE XSI, SolidWorks, and Wavefront compatibility, as well as generic shader libraries such as mental images' base, physics, and Lume shader libraries.
Some shaders accept a boolean parameter shadow that turns shadow casting on or off for that light source, and a floating point factor that is the shadow factor. The shadow factor controls penetration of opaque objects. The computation of shadows is a responsibility of light shaders in mental ray; in order to compute transparent shadows this may involve the cooperation of shadow shaders attached to semi-transparent shadow-casting objects.
For example, the mib_light_spot shader in the base shader library implements a spot light. It has a color parameter that must be set to the color of the light, as three scalars for the red, green, and blue components. It also allows a boolean shadow parameter that enables shadows cast from this light if its value is on, and a factor parameter that controls shadow penetration, ranging from 0.0 for black shadows to 1.0 for invisible shadows. The shader also accepts a boolean atten parameter that turns distance attenuation on or off, and two scalar parameters start and stop that specify the range over which the attenuation falls off if atten is on. The spot light mode requires an origin, a direction, and a spread value in the light definition in the scene description file. The spread value in the light definition and the cone parameter of the shader together define the spot characteristics of the light. The cone parameter specifies the angle of the inner solid cone and the spread statement specifies the outer falloff cone. The spot casts a cone of light with a softened edge where the intensity falls off to zero between the cone and spread angles. This and most other shaders specify angles not in degrees but in the cosine of one-half of the opening angle to improve performance: 1.0 is an opening angle of 0 degrees (a laser beam too narrow to see), 0.707 specifies an opening angle of approximately 90 degrees (because cos ) and 0.0 specifies an opening angle of 180 degrees.
home | << prev | next >> | contents |
Copyright © 1986-2006 by mental images GmbH