There are several functions for setup lighting. The general function is light which switch on/off the lighting for overall plot. It influence only for graphics which created after light call (with one exception, OpenGL). Generally MathGL support up to 10 independent light sources. But in OpenGL mode only 8 of light sources is used due to OpenGL limitations. The position, color, brightness of each light source can be set separately. By default only one light source is active. It is source number 0 with white color, located at top of the plot. See Lighting sample, for sample code and picture.
[val=on] ¶mglGraph: bool Light (bool enable) ¶void mgl_set_light (HMGL gr, int enable) ¶Sets the using of light on/off for overall plot. Function returns previous value of lighting. Default value is lightning off.
num val ¶mglGraph: void Light (int n, bool enable) ¶void mgl_set_light_n (HMGL gr, int n, int enable) ¶Switch on/off n-th light source separately.
num xdir ydir zdir ['col'='w' br=0.5] ¶num xdir ydir zdir xpos ypos zpos ['col'='w' br=0.5 ap=0] ¶mglGraph: void AddLight (int n, mglPoint d, char c='w', mreal bright=0.5, mreal ap=0) ¶mglGraph: void AddLight (int n, mglPoint r, mglPoint d, char c='w', mreal bright=0.5, mreal ap=0) ¶void mgl_add_light (HMGL gr, int n, mreal dx, mreal dy, mreal dz) ¶void mgl_add_light_ext (HMGL gr, int n, mreal dx, mreal dy, mreal dz, char c, mreal bright, mreal ap) ¶void mgl_add_light_loc (HMGL gr, int n, mreal rx, mreal ry, mreal rz, mreal dx, mreal dy, mreal dz, char c, mreal bright, mreal ap) ¶The function adds a light source with identification n in direction d with color c and with brightness bright (which must be in range [0,1]). If position r is specified and isn’t NAN then light source is supposed to be local otherwise light source is supposed to be placed at infinity.
val ¶mglGraph: void SetDiffuse (mreal bright) ¶void mgl_set_difbr (HMGL gr, mreal bright) ¶Set brightness of diffusive light (only for local light sources).
val ¶mglGraph: void SetAmbient (mreal bright=0.5) ¶void mgl_set_ambbr (HMGL gr, mreal bright) ¶Sets the brightness of ambient light. The value should be in range [0,1].