Fog component to easily design fog using editor or code

Posted on

Adding fog component
Making fog component active on viewport
Adjust fog parameters
Fog and background colors matching

Fog can be now added and configured using TCastleFog component. The component is also available in CGE editor, so you add and configure your fog without even writing any code.

The usage is simple:

  1. You add a fog component anywhere to the design using “Add Non-Visual Component -> Fog (TCastleFog)” in editor.

  2. You set it as active for given viewport by adjusting the TCastleViewport.Fog property.

  3. Adjust the fog parameters, like TCastleFog.Color and TCastleFog.VisibilityRange, as you wish.

  4. Optionally, you can adjust the background color to match the fog color. The fog looks most natural in this case. You can just adjust TCastleViewport.BackgroundColor and leave TCastleViewport.Background empty (nil) for a simple background color. See more about backgrounds.

I reiterated this in a simple manual chapter about fog.

The fog behavior in combination with Linear color space (gamma correction) also changed. Fog is now applied in final (sRGB) color space, this allows to match fog color perfectly to background color or UI easily.

Start the discussion at Castle Game Engine Forum