User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mapping:cawe:lighting [2005-09-14 13:36]
Carsten created
mapping:cawe:lighting [2013-01-07 12:07] (current)
Line 1: Line 1:
-====== ​Everything about Lighting (Radiosity, Dynamic ​LightsShadows, Sky Light, ...) ======+====== ​About Lights ​and Shadows ======
  
-FIXME  This page is //really// outdated and incomplete. All types of light sources should be mentioned hereRadiosity area light sources +FIXME  This page is still under construction :!
-(whose irradiance is defined with the material), radiosity point light source entities, dynamic light+shadow entities, sky light, ... (anything else?)+
  
 +One of the key questions that mappers frequently raise is how to define and place light sources.
 +While placing light sources is generally easy, this section explains the types of available lighting techniques in Cafu and the options to create light sources for each.
  
-===== Radiosity ​Area Light Sources =====+The Cafu engine implements two different types of lighting techniques:​ 
 +  * Radiosity-based lighting and 
 +  * dynamic lighting.
  
-Nearly every texture in ''​Games/​DeathMatch/​Textures''​ that looks like a light sourceis light source. +The two lighting techniques are quite distinct from each otherand each comes with set of feature of its ownNonethelessboth techniques peacefully coexist in the Cafu engine and mappers frequently employ both in single map.
-That issuch textures are defined to actually emit light. +
-Thus, there is hardly ever a need to use "​Isotropic Point Light" entities at all. +
-Please have a look into the ''​CaLight.cfg''​ file for list of textures that emit light, +
-but for future compatibility you should not make changes in this file (except for your own new textures).+
  
  
 +===== Radiosity-based Lighting =====
  
-===== Sky Light =====+One of the most fundamental lighting techniques in computer graphics is the [[wp>​Radiosity]] method. 
 +Radiosity methods compute lighting based on a physical model, and it is the nature of the underlying mathematics that characterizes the features of the technique.
  
-You can add sky domes to your world by applying the "​sky"​ texture to the "​ceiling"​ surfaces. +The big downside of Radiosity is that it requires a preprocessing step. This preprocessing step can be computationally very expensive ​and thus take long time to completeIt is implemented ​in a special tool called "​CaLight",​ which is one of the map compilers ​that are covered in sections ​[[mapping:compiling_new]] and [[mapping:compiling]].
-You also have to set the sky name, sunlight direction, ​and sunlight irradiance (intensity and color) in the **Map properties** dialog. +
-The table below lists few examples in order to give you a rough idea about what to enter. +
-(Don't worry if you have initially forgotten to enter these settings ​in the **Map properties** dialog. +
- The CaLight tool that you will use later gives you a second chance to override them (see section ​[[Mapping::Compiling#​CaLight]]).)+
  
-Example values for sky dome and sunlight settings (to be set in the CaWE **Map properties** dialog): +The fact that Radiosity is slow to precompute also means that it cannot work with dynamic objects: Radiosity takes walls and any other static object into account, but anything that moves will not influence ​the Radiosity-based lighting result.
-^ AEonsCube (cold moonlight): ​        ^^ +
-| skyname ​           |           Snow2 | +
-| sun_direction_x ​   |               2 | +
-| sun_direction_y ​   |              -5 | +
-| sun_direction_z ​   |              -9 | +
-| sun_irradiance_r ​  ​| ​              2 | +
-| sun_irradiance_g ​  ​| ​              4 | +
-| sun_irradiance_b ​  ​| ​              6 | +
-^ CastleMF (warm light of a sunrise): ^^ +
-| skyname ​           |      Nottingham | +
-| sun_direction_x ​   |               3 | +
-| sun_direction_y ​   |              -6 | +
-| sun_direction_z ​   |              -3 | +
-| sun_irradiance_r ​  ​| ​            100 | +
-| sun_irradiance_g ​  ​| ​             63 | +
-| sun_irradiance_b ​  ​| ​             30 | +
-^ JrBase1 (warm daylight): ​           ^^ +
-| skyname ​           |          T_red5 | +
-| sun_direction_x ​   |              -6 | +
-| sun_direction_y ​   |               5 | +
-| sun_direction_z ​   |             -12 | +
-| sun_irradiance_r ​  ​| ​            100 | +
-| sun_irradiance_g ​  ​| ​             90 | +
-| sun_irradiance_b ​  ​| ​             80 |+
  
 +Good news about Radiosity-based lighting is that once the preprocessing step it complete, it is //fast//. Independently of the number of light sources or complexity of the scene, Radiosity-based lighting provides very good performance at run-time during the game. It is therefore a natural choice for large-scale base lighting of any level.
 +
 +Even better, Radiosity lighting results looks stunningly good. No matter what hardware vendors tell you about their latest products, no matter what game developers tell you about dynamic lighting (as I do, too; see below), none of these techniques can beat the realism of lighting generated by Radiosity methods. Based on an accurate physical model, the natural propagation and appearance of lights and shadows is unique to Radiosity methods.
 +
 +The Radiosity method also handles //area light sources// without special measures, but as a natural part of the algorithm. Area light sources are an important key feature, because they are the main contributors to a realistic lights and shadows distribution with diffuse reflections and soft shadows.
 +This is contrary to dynamic lighting, where lights are only points in space, soft shadows are always the result of some kind of trick, diffuse reflections are not possible at all, and a physical model is never involved.
 +
 +For these reasons, Radiosity was the first lighting technique implemented in Cafu.
 +
 +Here is an overview of the available Radiosity light sources and how they are created in a map:
 +
 +
 +==== Area Light Sources ====
 +Any primitive (brush or Bezier patch) surface that you place in a Cafu map can be turned into an //area light source//. The key point here is that a surfaces characteristic of being an area light source is //not// :!: directly set in the Cafu World Editor CaWE. Rather, being an area light source is a //​material//​ property.
 +That means that a surface becomes an area light source when it has a material applied to it which in turn is defined to emit Radiosity light.
 +
 +  * In order to place an area light source, use the [[mapping:​cawe:​editingtools:​editfaceprops|Edit Surfaces]] tool to apply an appropriately defined material to the desired brush or Bezier patch surface. You can learn which materials cast Radiosity area light by clicking on them once in the [[mapping:​cawe:​materialbrowser|Material Browser]]. The bar at the bottom will show "​Radiant Exitance"​ information on the selected material, if any.\\ Tip: Filter for materials with the string "​light"​ in their name. This heightens the chance to find a relevant material quickly.
 +  * In order to change the definition of a new or existing material to emit light, make sure that the ''​meta_radiantExitance''​ keyword is employed. Please refer to the Material Systems [[matsys:​cmat_manual:​keywordreference]] for more details.\\ Note that the effect of changing the definition of an //​existing//​ material is //global//. That is, if the material is used elsewhere (in another map), also the other map will be affected when CaLight is run next.
 +
 +
 +==== Point light sources ====
 +You can also place //point light sources// to participate in the Radiosity lighting process.
 +This is easily achieved with the [[mapping:​cawe:​editingtools:​newlight|New Light tool]], whose documentation explains the placement and parameter setup in detail.
 +
 +
 +==== Sky Light ====
 +Adding sun- or moonlight to a map works analogously to adding an area light source: Just apply a "​sky"​ material to any surface, and if the material is defined to emit skylight, everything else will happen automatically:​
 +
 +  * The [[mapping:​cawe:​materialbrowser|Material Browser]] browser informs you whenever a material with "​Irradiance"​ values is selected.
 +  * The material definition can be changed according to the Material Systems [[matsys:​cmat_manual:​keywordreference]],​ see the ''​meta_sunlight''​ keyword.
 +  * You may refer to the [[mapping:​cawe:​yourfirstmap]] tutorial to see an example. It's actually that easy!
 +
 +
 +===== Dynamic Lighting =====
 +
 +Dynamic lighting has become popular with the advent of hardware-acceleration for 3D graphics in the recent years.
 +It is the preferred and most frequently employed lighting technique in most recent commercial graphics software.
 +
 +The essential characteristic of dynamic lighting is that its computational steps occur //​per-pixel//​ and //​per-frame//​.
 +//​Per-pixel//​ means that the lighting computations occur on the basis of the output pixels of the rendered primitives (triangles).
 +//​Per-frame//​ refers to the fact that all lighting computations occur only at runtime, and in fact, they are performed for each rendered frame anew. This allows both light sources and lit objects to move arbitrarily through the scene, with the lights and shadows being updated correctly and instantaneously.
 +
 +These properties have many implications for the practical use of dynamic lighting:
 +Dynamic lighting is fast, flexible, dynamic, instantaneous,​ yields good results and is well supported and accelerated in hardware.
 +
 +Even though dynamic lighting looks not quite as real as the Radiosity method, this is often not a problem, because lighting that looks dramatically good is often preferred over the "​boring natural"​. Moreover, dynamic lighting avoids the computational complexity that comes with the Radiosity method. Therefore, dynamic lighting is an important component in Cafu.
 +
 +==== Point light sources ====
 +==== Projective lights ====
 +==== Stencil shadows ====
 +==== Shadow-Map shadows ====
 +
 +
 +===== Spherical Harmonics Lighting =====
 +
 +Lighting with [[wp>​Spherical_harmonics|Spherical Harmonics]] ("​SHL"​) is an area of active research in computer science. Its goal is to combine the merits of Radiosity-based lighting with light sources that can move, especially when the light sources are very far away from the scene, like for example the sun or the moon.
 +
 +SHL has been implemented in the scope of my diploma thesis in the Cafu engine, but is currently not supported by the public releases. You may refer to the thesis linked below for more information.
 +
 +
 +===== See Also =====
 +
 +  * [[http://​www.cafu.de/​files/​Uni-DA-RealTimeLighting.pdf|Methods for Real-Time Lighting]] -- Diploma (Masters) Thesis by Carsten Fuchs.
mapping/cawe/lighting.1126697799.txt.gz · Last modified: 2013-01-07 12:07 (external edit)