Interpolation between occlusion maps
In the Ice Cave demo, the script calculates the XZ projection of the camera position on the 2D cave map every frame, and normalizes the result between zero and one.
If the camera height is below Hmin or above Hmax, the normalized coordinates are used to fetch the color value from a single map. If the camera height is between Hmin and Hmax, the color is retrieved from both maps and interpolated.
This interpolation creates a smooth transition between the effects at different heights.
The Ice Cave demo uses the
GetPixelBilinear() function to retrieve the colors from the map or maps.
This function returns a filter color value using the following code:
float groundOcclusionFactor = groundOcclusionMap.GetPixelBilinear(camPosXZNormalized.x, camPosXZNormalized.y)).r;
Using the bloom occlusion maps prevents the blending of the bloom on top of occluding opaque object. The following figure shows the resulting effect. When the camera is entering and leaving, the occluding black is behind the opaque plinth, preventing the incorrect bloom.
The following figure is sequence showing the camera entering the occluding zone behind an opaque plinth:
Figure 6-69 Entering the occluding zone behind an opaque plinth