Graphics Reference
In-Depth Information
GV_lsr_create( &room_light ); // Create a local light
GV_lsr_set_name( room_light, "ROOM " );
GV_lsr_set_position( room_light, &light_position ); // Set Position
GV_lsr_set_direction(room_light, & light_direction );// Set direction
2.3
Spotlight
One can also set the light to make it look like the spotlight. For example, set the shape
of the light source a conical shape. The spotlight was actually a point light source with
irradiation direction and coverage. It's the same to create an infinite light, create a
spotlight needs specific property setting functions.
2.3.1 Irradiation Direction of the Spotlight
The irradiation direction of the spotlight was different from infinite light source. Di-
rection of the light spotlight means the direction of the light.
G_Vector3 light_direction = { 0.0, 0.0, -1.0 };
GV_lsr_set_spot_direction(spotlight, &light_direction );
The above procedure sets the irradiation direction of a point source from the point
light source to Z-axis negative direction.
2.3.2 Position of Spotlight
The light source position was the position where the light source was, the meaning of
which was the same with the local light position.
G_Position world_position = { 0.0, 0.0, 0.0 };
GV_lsr_set_position(spotlight, &world_position );
2.3.3 Cone Angle of the Spotlight
By default, the angle of a point light source is 180 °, light launch in 360 °, so it was not
a cone. It is necessary to specify the angle between the sides of the cone along the axis
of the cone.
float cutoff_angle = 30.0 * G_DEG_TO_RAD;
GV_lsr_set_spot_cutoff(spotlight, cutoff_angle );
2.3.4 Attenuation Parameters Spotlight
There are four parameters of light attenuation, attenuation constant, linear attenuation
parameters, quadratic attenuation parameters and light intensity index [1]. The spot-
light light attenuation parameters were from scene after commissioning. The attenua-
tion constant, linear attenuation parameters and quadratic attenuation parameters
directly affected the size of the parameter of the light intensity index, and further af-
fected the intensity of the light source [2].
float d = 50.0; // the limit distance of light irradiation
float kc = 0.5; // attenuation constant
float kl = 0.0001; // Linear attenuation parameters
float kq = 0.0001; // quadratic attenuation parameters
float attenuation = 1.0 / (kc + kl*d + kq*d*d);
Search WWH ::




Custom Search