Radiosity

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

From Wikipedia:

Radiosity, in heat transfer, is the total radiation (reflected plus emitted) leaving a surface. In a cavity containing several different surfaces, it is used with a matrix calculation method to solve for all temperatures and heat exchanges between all of the surface at steady state.

In 3D computer graphics is a rendering algorithm which gives a more realistic rendering of shadows and diffuse light, by applying the above approach in addition to raytracing.

How it works in TDM

The Dark Mod has a (very limited, but useful) approach to fake radiosity by manipulating the main ambient light named "ambient_world".

In TDM, each map has only one ambient light, and this can be modified according in which zone the player currently is. This alone allows for effects that you get a bluish outdoor ambient, but a dark-green basement ambient or a reddish lava-cave ambient. The code does fade the light slowly from one color to the other when the player changes the zone. Both the light colors and the fading time can be adjusted on a per-zone basis.

In addition to just fading the light, the code also allows for "dynamic ambient light", e.g. poor-mans radiosity. Here the code just takes all the lights in the current zone, calculates some "light sum" for them, scales it down and then adds this the current ambient light.

These changes occur multiple times per second and always fade the light over the next 0.X seconds to the new value, still taking into account the (maybe still fading) main ambient light.

This means strong light chances introduce subtle changes in the ambient light - extinguish a fire and the room goes slightly darker (and less yellowish). Due to the fast-changing nature the ambient light even slowls pulsates with changes f.i. from fireflames.

See also