Light schemes for 3D graphics
|Objects||Lighting Default Values|
Lighting determines the light scheme used to illuminate a 3D scene.
With the default Lighting = Automatic, several light sources are set automatically to illuminate a 3D scene. Firstly, there is ambient white light of type plot::AmbientLight:
Light 0: LightIntensity = 0.25, LightColor = RGB::White
In addition, there are 6 directed lights of type plot::DistantLight with LightColor = RGB::White. Their directions is given as follows: Think of the graphical scene as being scaled to a standard box extending from - 1 to 1 in each coordinate direction. In these scaled coordinates, the directed lights shine into the directions given by the following Target attributes:
User-defined lights in the scene are ignored with Lighting = Automatic.
With Lighting = Explicit, the light sources set via Lighting = Automatic are switched off and user-defined light sources are switched on.
A plot command searches for light objects set by the user. If Lighting is not specified and any kind of user-defined light object is found in the scene, Lighting = Explicit is set automatically.
Switching between Lighting = Automatic and Lighting = Explicit in the inspector, one can easily compare the effect of the automatic lights with the effect of ones own lights.
With Lighting = None, the 3D shading algorithm based on reflections of light emitted from light sources in the graphical scene is switched off. This does not mean that the graphical scene turns black: all objects are painted in the color they are defined with. However, the scene will appear flat, because the depth of a 3D scene is created via the shading caused by different reflections of light at different points of the scene.
The maximal number of lights that can be used to illuminate a 3D scene depends on the OpenGL® driver installed on the computer.
Note: Some OpenGL drivers do not allow more than 6 light sources. If there are more light sources in the scene, the surplus lights are ignored. Lights that are switched off via Visible = FALSE are not counted.
After activating a 3D plot (by clicking it), the "Help" menu contains an item "OpenGL Info" that provides information about the maximal number of lights.
In our first scene, no lights are specified. The default setting Lighting = Automatic is used:
f := plot::Function3d(sin(x^2 + y^2), x = -2..2, y = -2..2): plot(f):
When specifying Lighting = Explicit, the lights set by the user are used. Since the scene does not contain any lights, the scene turns dark:
plot(f, Lighting = Explicit):
Lights are specified in the next scene. The setting Lighting = Explicit is used automatically:
Light0 := plot::AmbientLight(0.25): Light1 := plot::DistantLight([ 1, 0, 1], [0, 0, 0], 0.3): Light2 := plot::DistantLight([-1, 0, 1], [0, 0, 0], 0.3): Light3 := plot::DistantLight([ 0, 1, 1], [0, 0, 0], 0.3): Light4 := plot::DistantLight([ 0, -1, 1], [0, 0, 0], 0.3): plot(f, Light0, Light1, Light2, Light3, Light4):
We switch off the parameter lines:
plot(f, Light0, Light1, Light2, Light3, Light4, XLinesVisible = FALSE, YLinesVisible = FALSE, Axes = None):
In the next scene, the 3D shading model is switched off via Lighting = None:
plot(f, Lighting = None):
In the previous picture, the axes box and the mesh lines are switched on and create a certain 3D effect. After switching the box and the mesh lines off, the scene appears flat when rendered without shading:
plot(f, Lighting = None, Axes = None, XLinesVisible = FALSE, YLinesVisible = FALSE):
delete f, Light0, Light1, Light2, Light3, Light4: