Texture Maps
The file Vgbpoly3.asm contains the texture mappers. The texture mappers display textures as shown in the following example.
for (texture screen scan line = first, texture screen scan line = last, scan line++){
map scan line start point to the texture
t1 = distance to start point
haze_distance = t1
map scan line end point to texture
t2 = distance to end point
delta_haze = t2-t1
for (pixel = 1st, pixel = last, pixel++){
put texture x,z location (x3d2,z3d2) in location_buffer
put haze distance in haze_buffer
x3d2 = x3d2 + dx3d
z3d2 = z3d2 + dz3d
haze_distance = haze_distance + delta haze distance
}
}
At the end of the preceding example, the location_buffer has the x,z source texture coordinates and the haze_buffer has the distance for each point on the texture line. The following example shows what the texture mapper does with this information.
for (pixel = 1st, pixel = last, pixel++){
screen pixel = haze_table ( 256* haze_distance + texture source color (x,z))
}
The distances to the texture are critical in creating the haze_buffer. The value T1
is calculated by a macro called TMAP2 in the file Vgbpoly3.asm. Because the values to the texture aren't in meters, but rather in local coordinates, the T1
output value must be compensated for scale factor. Compensation for local visibility is lumped in with this scale compensation. The result is the haze table row index to the texture at the sample point shown in the following example.
t1=haze table row index of texture = dist to texture in design units * 8192
local_scale_factor * local_visibility
Points
When a haze driver is installed, whenever a point is drawn, the PNTPRJ routine in Ugi86sh3.asm computes the Z-distance to the point (after rotation and translation) in 2-meter units. The resulting value is passed in the eax register to Vgb2d.asm vgb_subpixpoint_32. This maps the submitted color to a haze color based on the formula shown in the following example.
haze table row index1=min (point_distance / (average_visib / 256 +1) , 15)
haze table row index=haze table row index1
where:point_distance=Z distance to point in 2-meter units
If the distance above the last SCALE command's y value (ybias) > haze_height, the plane is above the haze layer and the formula shown in the following example is used.
haze table row index=haze table row index1 * haze_height / ybias
And, the final step in the texture mapping process is shown in the following example.
output color= haze_table (256 * haze table row index + input color)
Points use the output color as their color value.
Note: Cumulus clouds are hazed if the plane is below the base of cloud layer 1; they aren't hazed if the plane is above the base of cloud layer 1.