Dynamic ambient light: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Datiswous (talk | contribs)
m →‎Downside: we do have the source now
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
Having one global ambient light is good for performance, but depending on your map the player might see various locations which all should have their own lighting setup. For instance, a slightliy bluish moonlit outside, a greenly lit cellar, or a dark-red underground cave with lava pits.
Having one global ambient light is good for performance, but depending on your map the player might see various locations which all should have their own lighting setup. For instance, a slightliy bluish moonlit outside, a greenly lit cellar, or a dark-red underground cave with lava pits.


To achive different looking ambients without having multiple ambient lights, there exists a [[Location Settings|zoning]] system. For each zone, you can set:
To achieve different looking ambients without having multiple ambient lights, there exists a [[Location Settings|zoning]] system. For each zone, you can set:


* a different base ambient color,  
* a different base ambient color,  
Line 16: Line 16:
=== Downside ===
=== Downside ===


While having only one global ambient light is good for performance, there is a downside: the entire visible world is colored according to the place the player is in. That means if you look from a reddish lava cave to the outside, you can also see the outside reddish tinted. This is also the case in many other games, and harder to fix than you think, especially since we do not have the source to Doom3 yet.
While having only one global ambient light is good for performance, there is a downside: the entire visible world is colored according to the place the player is in. That means if you look from a reddish lava cave to the outside, you can also see the outside reddish tinted. This is also the case in many other games, and harder to fix than you think.
 
One common practice is to build intermidiate areas, for instance an L-shapped corridor. In this zone a neutral grey ambient is used, and so the player notices the transition less.


One common practice is to build intermediate areas, for instance an L-shaped corridor. In this zone a neutral grey ambient is used, and so the player notices the transition less.


== Dynamic Ambient Light Spawnargs ==
== Dynamic Ambient Light Spawnargs ==

Latest revision as of 09:24, 9 June 2023

Introduction

The ambient light is used to provide a base color to all visible surfaces, hereby avoiding the pitch black shadows that appear on surfaces hit by no light at all. It should 'complement the main lighting, but not be the only light of a room except in some rare cases.

In TDM, this is achieved with exactly one global light entity named ambient_world.

Having one global ambient light is good for performance, but depending on your map the player might see various locations which all should have their own lighting setup. For instance, a slightliy bluish moonlit outside, a greenly lit cellar, or a dark-red underground cave with lava pits.

To achieve different looking ambients without having multiple ambient lights, there exists a zoning system. For each zone, you can set:

  • a different base ambient color,
  • a time the code waits, and a time it takes to fade to this color (to avoid abrupt color changes)
  • as well a dynamic part, which gets added to the base ambient.


Downside

While having only one global ambient light is good for performance, there is a downside: the entire visible world is colored according to the place the player is in. That means if you look from a reddish lava cave to the outside, you can also see the outside reddish tinted. This is also the case in many other games, and harder to fix than you think.

One common practice is to build intermediate areas, for instance an L-shaped corridor. In this zone a neutral grey ambient is used, and so the player notices the transition less.

Dynamic Ambient Light Spawnargs

The dynamic part of the ambient light is calculated in real-time from the lights in the current zone, and optionally their distance to the player. It is then multiplied with a per-zone factor: so in a small white room the ambient has a higher influence, and is basically whitish, while in a red underground cave it has much less influence and is reddish.

ambient_light

The base color of the ambient light for this zone. Example: "0.06 0.03 0.03" Avoid values greater than 0.10 unless you plan on making a daylight mission.

ambient_dynamic_light

A factor with which each light in the current zone is multiplied before being added to the ambient_light. Default is "0.01 0.01 0.01". Use for instance "0.04 0.01 0.01" for a reddish tinted ambient light. If you want to turn this feature off (but you really shouldn't, instead set ambient_light_falloff = 2 and use a sensible default), then use "0 0 0" as spawnarg.

ambient_dynamic_light_cap

The absolute limit for the dynamic part of the ambient light. Used to stop the ambient dynamic part overbrightening the ambient for this zone. Default is "0.1 0.1 0.1".

ambient_light_falloff

Default: 0 (Best looking is 1, and it has exactly the same performance as 0! So you really should use a value of 1.)

Here is an overview of how the dynamic ambient light inside a zone works. To make it more clear, only a 2D cut is shown through the room, albeit the feature works in 3D:

See also