|
Set the vertex fog value
Using this function one create interesting effects like setting
the fog for only specified areas. For example setting fog
only till a specific height or confining the fog in some volume.
This value is relevant only when FOG_MODE_VERTEX is used.
To set FOG_MODE_VERTEX call STATE_engine_set_fog() once after loading the world
For example: STATE_engine_set_fog(ON, 200, 200, 200, FOG_MODE_VERTEX, 1000000, FOG_START_DISTANCE_DEFAULT, 0);
Note that in the FOG_MODE_VERTEX the points fog value are not updated automatically.
It is up to the program to modify them. For example lets assume that you set a black fog color
to simulate night and now you set all the points in the world with values relative to the distance
of the point from the camera (as if the camera is also a light source and whatever is closer
to the camera is brighter). This will give a very nice effect but when the camera moves this process
has to be repeated otherwise the dark\lit area wont be updated !
This is nor very effective since updating all the points is time consuming
Therefor vertex fog is usually used for static light effects (see below) or to confine fog
to specific areas
Vertex fog also can be used as light ! In many cases it even gives better results than using 3DSTATE_light API
To understand when to use what and what can actually be achieved it is important to understand the following:
Each point has three RGB bytes that controls the red green and blue channel. When we have a bitmap/texture on a polygon
(this would usually be the case) the final color of a pixel on the screen is the bitmap pixel multiply by the
the color as contributed from the polygons vertices/points (unless STATE_bitmap_set_operation_mode() is called). Before multiplyong the color
with the bitmap pixel the color is scaled to the range [0 - 1]. For example the color gray (128,128,128) will
be scaled to (0.5, 0.5, 0.5). The important thing to remember here is that when manupulating the point rgb
the final result rendered on the screen will never be brighter than the bitmap it self. Using the point RGB
one can only darken the scene ! The STATE_light API actually manipulate the points RGB to create the illusion
of light. And here we get to the important advantage of vertex fog. When using the vertex fog the result rendered
pixel is between the fog color and the bitmap pixel. So we can actually get colors that are brighter than the bitmap !
Parameters:
fog_intensity:
A number between 255 and 0
Note that 0 is actually the maximum fog
and 255 would give the original color of the bitmap
The default is 255
Example:
STATE_point_set_fog(point_handle, 128); The result color in this case will be exactly in the middle between
the original bitmap color and the fog color
|