My program doesn't have bugs. It just develops random features.

Legacy:Distance Fog

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Distance Fog is sometimes called "true fog." Distance fog tints the screen as with view fog, but the degree of tinting is determined by the distance that a given pixel is from the camera. View fog has a uniform color independant of the distance you are from an object. Objects further away will apear to "fade away" into the distance fog. Note, however, that the SkyBox is not affected by the fog on your level, but you can add fog into the skybox as well.

Unlike View Fog, Distance Fog has to check a lot of distances every frame and this can have an impact on performance. However, some types of distance fog allow the engine to reject objects beyond a certain distance, which usually results in a net speed boost: this distance fog may be a useful tool in Map Optimization.

Distance fog may not show up in UnrealEd, and can be tuned in-game using the editactor console command to find the optimum values. Note, however, that distance fog may not obscure the coronas from lights.

Setting Up Distance Fog in Unreal Tournament[edit]

Firstly, you have to set the bFogZone variable in the ZoneInfo of every zone you wish to be able to see distance fog in. The zone that the fog is actually in will be the ones that the fog actually exists in, but distance fog calculations are skipped entirely if the camera is in a zone with bFogZone false. On the downside, however, decals will not be displayed properly in a zone with bFogZone true, so bFogZone should be left false unless fog is actually likely to be seen from the zone in question.

Xian: Is there a way to set the distance or size the fog occupies in UT99 ? FogDistance doesn't seem to be used.

Finding the Right DistanceFog Color for Your Map[edit]

A helpful trick to find the right color fog is to take a screenshot of your map (use togglescreenshotmode to hide the hud and crosshairs)while in game with distance fog turned off so you can get a good spectrum of all the colors your map is made of. Get this screenshot into PS and then change the mode to indexed color. Forced can be set to none since you don't need black or white for our purposes. Once that is done go to image>mode>color table... And then save that color table. Now in the swatches pallete replace the swatches with that color table. Note that you will have to change the file type in the load dialog to color table otherwise PS thinks you are just looking for swatch files. Now that this pallete is loaded you should have no problems finding a color which complements your level.

Setting Up Distance Fog in UT2003[edit]

There are two ways to set up distance fog in UT2003, with a ZoneInfo or with a PhysicsVolume. The main difference is that only "Zone Fog" occludes, so "Volume Fog" can't be used for optimizing framerates.

Zone Fog[edit]

Zone-based Distance Fog is set up similarly to distance fog in UT. Create a zone where you want fog, Add an Actor >> Info >> ZoneInfo, and set some variables. Specifically those variables are:

ZoneInfo -> bDistanceFog 
Enable distance fog in this zone.
ZoneInfo -> bClearToFogColor 
Always set this if the player can see past the FogEnd distance. This colors your fogcolor past that distance, instead of a HOM
ZoneLight -> DistanceFogBlendTime 
fade time when entering this zone. Only has an effect if the zone the camera is moving from also has bDistanceFog=true.
ZoneLight -> DistanceFogColor 
Color of the fog. The A value seems to be ignored.
ZoneLight -> DistanceFogBegin  
Distance in front of the camera that fog becomes visible, measured in UU. For a natural effect this should probably be small (< 2000).
ZoneLight -> DistanceFogEnd  
Distance in front of the camera that the fog becomes 100% opaque.

One big benefit of using zone fog in your map in addition to adding atmosphere is that it allows the engine to discard objects and entire zones if they're beyond the DistanceFogEnd distance, which can result in a big speed boost in some maps.

Volume Fog[edit]

Before we start, there's one important fact about Volume-based fog that you should know: It doesn't occlude. If you're trying to optimize your level use zone fog, as volume fog won't do anything for you (in fact it might make it run a bit slower due to the extra blending, but I'm not sure about that).

Volume-based distance fog is very similar to to View Fog in UT2003. You must place a PhysicsVolume to cover the area that you want the fog to affect, but instead of setting the ViewFog variables, you will need to set four variables under the "VolumeFog" group.

This is a boolean variable indicating whether or not distance fog calculations should be done. If you want to use distance fog, this must be set to true. By default, it is set to false.
This is a color variable that specifies, simply enough, the color that you want the fog to be. The alpha of the color will be determined by the distance that the object being viewed is from the camera.
This is the distance at which fog cover is absolute. Everything at this range and beyond will be totally obscured. However, if the skybox does not contain fog, these objects will actually be silhouetted against the sky. (Because the object itself will be completely colored over but the sky behind it will be unaffected.)
This is the distance at which fog calculations begin. Anything closer than this distance to the camera will not be fogged at all.

Interestingly, if you set DistanceFogStart to be GREATER than DistanceFogEnd, you will get inverse fog. Objects will become more obscured the CLOSER you get to them.