Skip to content

Spherical Fog

Narta Xaymar Dirks edited this page Oct 29, 2026 · 1 revision

Spherical fog

The fog of Blitz3D is computed from the depth of a point, how far it is along the direction the camera looks (the distance to the near plane). A flat wall in front of the camera has the same depth everywhere, so the fog is the same over the whole wall, and objects at the edge of the picture are as clear as those in the middle although they are further from the eye. When the camera turns on the spot, objects move in and out of the fog.

CameraFogMode 2 uses the straight line distance from the camera position to the point instead, so the fog forms a sphere around the camera. The range from CameraFogRange and the color from CameraFogColor work the same as for mode 1. Modes 0 and 1 are not changed, and any other value than 2 is linear fog like 1 as before.

The 3D vertex shader passes the position of the point relative to the camera to the pixel shader next to its depth, and the pixel shader takes the length of the interpolated position for every pixel. That makes the fog exact on each pixel and not only on the corners of a triangle (taking the distance per vertex and interpolating it would turn the round fog into visible triangles on big surfaces such as floors and planes). The only cost is the three values more that the vertex shader passes on, whichever mode is on.

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally