|
Activates the light automatically before each render.
The usage of this function is for dynamic lighting.
If the light source moves every render (or other property of the light is changed)
then the light has to be updated as well
If however the light source properties do not change between every render then you
should not use this method (it will waste CPU time).
Another use for this method is for lighting dynamic objects.
Again use it only if the dynamic object moves or rotates every render
otherwise it is better to call STATE_light_activate() explicitly after
each time that the object changes its position.
Parameters:
light_operation:
Determines how the light is going to be activated every render.
possible values are: LIGHT_ADD, LIGHT_SUBTRACT and LIGHT_SET
Normally you would give LIGHT_SET. The other two options can be
used for creating special effects like gradually darkening the world
or a "get killed" effect when the screen turns into red (using a red colored light)
The light_operation argument is only relevant if YES_or_NO==YES
YES_or_NO:
YES to enable. Give No to stop activating the light before each render. The default is NO
Important:
Dynamic lighting can be very slow if not done correctly. Note the following points:
1) Never light the whole world every render. Instead light only the moving objects that need to be re-lighted
2) Don't use ray tracing for dynamic lighting.
See example "C" below.
Examples:
A)
STATE_light_activate_before_each_render(my_light, YES, LIGHT_SET);
B)
Disable dynamic lighting.
STATE_light_activate_before_each_render(my_light, NO, 0); doesnt matter what number is given (for the light operation)
C) Creating fast dynamic lighting.
In this example, light sources are used to illuminate dynmaic (moving) objects.
STATE_light_set_entity_to_light(light1, object1);
STATE_light_set_entity_to_light(light2, object2);
STATE_light_set_type_of_light(light1, LIGHT_DEFAULT_FAST);
STATE_light_set_type_of_light(light1, LIGHT_DEFAULT_FAST);
STATE_light_activate_before_each_render(light1, YES, LIGHT_SET);
STATE_light_activate_before_each_render(light2, YES, LIGHT_SET);
|