Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
lighting
Lighting overview
Description
Lighting in scilab aproximates real world lighting where the appearence of a surface is given by interactions between light rays and the material properties of the surface.
Because simulate real world lighting is complex and computationaly expesive, one uses a simplified model.
A light is represented mainly by its colors: ambient, diffuse and specular. It can be created using light function, and deleted using delete function.
The surface material properties is represented also by its colors (ambient, diffuse and specular) and it shininess level.
The surface contains the color_material
property that enables
the use of the surface color as the diffuse color.
The final surface color is given by the light model equation applied to the product of the surface and light colors. Following there is the light model equation:
Ambient color models the light received indirect by the surface and is independent of the surface normal or light direction.
Diffuse color models the light received directly, and thus it's dependent of the light ray direction and the surface normal.
Specular color defines the specular highlight color.
Following one can compare the surface with and without lighting:
Lighting properties list
- Light properties
- visible:
This field defines if the light is enabled
"on"
or disabled"off"
.- light_type:
This field defines the type of light used. There are two types available:
"directional"
and"point"
. Directional lights are positioned infinitely far from the surface thus emitting parallel rays.Point lights are defined as a point in space thus emitting rays in all directions. The default value is
"point"
.- direction:
This field defines the ray direction for directional light. The direction can be chaged using a 3 element vector
"[x, y, z]"
representing a vector starting from the origin.The default value is
"[0 0 1]"
.- position:
This field defines the light position for point light. The position can be changed using a 3 element vector
"[x, y, z]"
.The default value is
"[0 0 1]"
.- ambient_color:
This field defines the ambient color of the light. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1].The default value is
"[0.1 0.1 0.1]"
.- diffuse_color:
This field defines the diffuse color of the light. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1].The default value is
"[1 1 1]"
.- specular_color:
This field defines the specular color of the light. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1].The default value is
"[1 1 1]"
.
- Surface properties
- use_color_material:
This field is use to enable the use of the surface color as diffuse color. Its default value is
"on"
.- material_shininess:
This field defines the shininess level of the surface. This parameter controls the shinines color spreading in the surface. Any positive value can be used.
Good values to use are in the [0 10] range, where low values generates strong highlight and high values generates barely perceptible highlights. The default value is
"2"
.- ambient_color:
This field defines the ambient color of the surface. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1].The default value is
"[1 1 1]"
.- diffuse_color:
This field defines the diffuse color of the surface. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1]. Notice that this field is only used when use_color_material is disabled.The default value is
"[1 1 1]"
.- specular_color:
This field defines the specular color of the surface. The color is defined by a 3 element vector
"[red, green, blue]"
with each element in the range [0, 1].The default value is
"[1 1 1]"
.
Examples
Point light without color_material:
plot3d(); s=gce(); s.color_flag=0; s.thickness=0; s.hiddencolor = -1; light(); //change diffuse color to orange s.diffuse_color = [1, 0.6, 0]; s.use_color_material="off"; //black spots turn dark orange s.ambient_color = [1, 0.6, 0];
Directional light:
See Also
- light — creates a light object in the given axes
- light properties — Light overview
- surface properties — description of the 3D entities properties
- delete — Deleta uma entidade gráfica e seus galhos
Report an issue | ||
<< light properties | lighting | GlobalProperty >> |