Skip to content
antz edited this page Apr 16, 2023 · 3 revisions

Why use Fog?

Fog is not only used for a graphical effect, but it is extremely useful for performance. Fog allows you set set a smaller camera far plane distance, which reduces the amount of work the GPU needs to do to draw your scene, by culling far away objects.

The reason you can set a smaller camera far plane distance is that the fog obscures this cut off distance.

Where do I set/modify the Fog settings?

Main Menu > Environment > Fog

image

From the Fog panel you can:

  • enable/disable fog (for this scene)
  • set near and far plane (similar to the camera settings)
  • set the gradient, which is the strength of the transition of opaqueness from weak to strong > near to far
  • select the color of the fog

How do I change the Fog settings in the runtime?

The MundusRuntimeExample repo has an example here.

Below is the specific code that allows you to change values of the Fog for the scene.

FogAttribute fogAttribute = (FogAttribute) scene.environment.get(FogAttribute.FogEquation);
fogAttribute.value.x = 100f; // Near plane
fogAttribute.value.y = 500f; // Far plane