Darkplaces lighting

From Blood Wiki
(Difference between revisions)
Jump to: navigation, search
m
m
 
(8 intermediate revisions by one user not shown)
Line 1: Line 1:
{{unfinished}}
+
[[File:Darkplaces_gl_lightmaps_2.jpg|400px|thumb|Map with only lighting applied]]
{{need screenshot}}
+
Lighting is one of the most important and influential elements in level design. It has the power to make or break the visuals, theme and atmosphere. Lighting is just as important as geometry. Without lighting there is no environment but just a group of 3-dimensional objects. Its purpose goes further than just giving the players the ability to see where they are going.
{{grammar}}
+
Darkplaces engine uses combined lighting model. Several lighting methods are implemented to give best results at cases they are aimed for.
+
  
== Lighting model ==
+
Darkplaces engine combines several lighting techiques in order to get best performance and best looks. Because of that there is lots of options and tricks. Clever usage of them will help designers to make fast-to-render and well themed maps.
[[File:Darkplaces lighting visualized.jpg|thumb|512px|Lighting visualized. Blue is shadow volumes, bright orange is zones being processed for dynamic realtime lighting.]]
+
Darkplaces uses a variation of Phong shading as a default lighting model. It is based on '''per-pixel lighting''' - a technique of computing lighting equations for each pixel independently. Renderer contains lots of tricks to allow shading to be fast and flexible. Default model is used on both GL2.0 rendering paths and pre-shader rendering paths (GL1.4), although not all lighting features are possible on pre-shader fixed rendering pipeline.
+
  
Lighting are breaked into the passes:
+
This reference will guide you in the deep dungeon of Darkplaces lighting methods, effects, tricks and quirks.
# Base pass (lightmap/lightgrid/vertex lighting)
+
# Dynamic light 1
+
# Dynamic light 2
+
# ...
+
# Dynamic light X
+
# Photon Mapping (optional)
+
# Fog (optional)
+
  
Basically Darkplaces lighting model involves this data to be processed for each pixel:
+
'''Important Note'''
* Vertex normal : values between vertices of pixel's triangle are interpolated by [http://en.wikipedia.org/wiki/Gouraud_shading Gouraud shading]
+
* Color Map : base texture (best way to use [[diffuse]] texture)
+
* Normal Map : texture storing additional surface curvature (optionally, alpha storing height)
+
* Gloss Map : texture is used for specular and containing gloss color (RGB) and exponent mod (alpha)
+
* Glow Map : texture's local luminance texture, RGB additive blended texture that entirely ignores shading
+
* Light Vector : vector of light direction (either calculated for realtime light or got from deluxemap [[lightmap]] component)
+
* Eye Vector : being computed for each pixel, this vector is used for specular calculation.
+
  
===Attenuation===
+
Textures are the base for lighting. Before starting to learn how lighting works, be sure to check out [[Darkplaces material system]] as many of it's concepts and features used by lighting too.
Dynamic lights in Darkplaces engine are omnidirectional, using linear falloff.
+
  
{{design|Spotlights and projected dynamic lights could be simulated with cubemap filters.}}
+
==Chapters==
 +
<font size=3>
 +
#[[Darkplaces lighting/Introduction|Introduction]]
 +
#[[Darkplaces lighting/Lighting model|Lighting model]]
 +
#[[Darkplaces lighting/Special effects|Special effects]]
 +
#[[Darkplaces lighting/Light sources|Light sources]]
 +
</font>
  
Static lights that is used for lightmap calculations are opposite. They have a variety of options for controlling attenuation (this options is only used in Q3map2 LIGHT stage):
+
==Appendix==
* target and radius : simulating spot lights with cone falloff
+
<font size=3>
* _sun flag - infinite distance lights, constant direction
+
* [[Darkplaces lighting/Additional options|Additional options]]
* _deviance and _samples - non-point lights
+
</font>
  
===Shading===
+
==Recommended articles==
Shading is done by using dotproduct of light vector and pixel normal. Some ambient lighting could be added for a more smooth result.
+
* [http://www.moddb.com/tutorials/lighting-in-game-environments-the-hows-and-whys Lighting in game environments - the hows and whys]
 
+
Rough shading algorithm explanation:
+
<font color=green>// Surface's vertex normals are always supplied, texture normalmap is forced to default RGB '128 128 255' if not found</font>
+
PixelNormal = Surface.VertexNormal + Texture.NormalMap;
+
<font color=green>// LightSource are only defined for dynamic lights</font>
+
<font color=green>// LightmapGlobal.AmbientLight is r_ambient cvar</font>
+
<font color=green>// Material.AmbientLight is set by '''dprtlightambient''' matrial keyword and only applicable to dynamic lights</font>
+
AmbientLight = LightSource.AmbientLight + LightmapGlobal.AmbientLight + Material.AmbientLight;
+
<font color=green>// Since LightSource are only defined for dynamic lights, for all static lighting it defaults to 1</font>
+
DiffuseLight = LightSource.DiffuseLight;
+
Shading = dotproduct(PixelNormal, LightVector) * DiffuseLight + AmbientLightAmount;
+
 
+
{{cvar|r_shadow_usenormalmap|Enables use of normalmap texture for lighting. Setting this to to will make only vertex normals to be used.}}
+
{{cvar|r_shadow_bumpscale_basetexture|Forces normalmap to be automatically calculated from color texture by using it as bumpmap, value controls magnitude. Requires r_restart.}}
+
{{cvar|r_shadow_bumpscale_bumpmap|Normalmap can be supplied as _bump texture, in this case engine converts it to normalmap on load, values is magnitude. Requires r_restart.}}
+
{{cvar|r_ambient|Amount of ambient light to be added to all surfaces. Makes level brighter.}}
+
 
+
===Specular===
+
Specular are optional and could be tweaked per-material.
+
 
+
Specular offers two parameters to mess with:
+
* Specular exponent : intensity of specular effect, this could be very high or very low. Basically its just a modifier to gloss texture.
+
* Specular power : how 'sharp' gloss is, high values are used to make texture to be plastic-like, while lower ones are suitable for matte surfaces. Basically its just a modifier to gloss texture's alpha channel (which is forced to 1 if not supplied).
+
 
+
Gloss may be forced (see r_shadow_gloss 2 below), in this case texture, if missing its own gloss map, gets a white image for gloss map and parameters from a cvars.
+
 
+
Rough specular algorithm explanation:
+
<font color=green>// Global.GlossIntensity is controlled by r_shadow_glossintensity or r_shadow_glossintensity2 if gloss is forced</font>
+
<font color=green>// Material.GlossIntensityMod is set by '''dpglossintensitymod''' material keyword</font>
+
SpecularColor = Texture.GlossMap * Global.GlossIntensity * Material.GlossIntensityMod;
+
<font color=green>// Global.GlossExponent is controlled by r_shadow_glossexponent or r_shadow_glossexponent2 if gloss is forced</font>
+
<font color=green>// Material.GlossExponentModis set by '''dpglossexponentmod''' material keyword</font>
+
SpecularExponent = Texture.GlossMap.Alpha * Global.GlossExponent * Material.GlossExponentMod;
+
<font color=green>// this is rough specular calculation</font>
+
<font color=green>// optionally, engine can use real reflection map to get specular normal (see r_shadow_glossexact below)</font>
+
SpecularNormal = PixelNormal + EyeVector;
+
Specular = SpecularColor * power(dotproduct(PixelNormal, SpecularNormal), SpecularExponent)
+
 
+
{{cvar|r_shadow_glossintensity|Global intensity for specular calculations, default is 1.}}
+
{{cvar|r_shadow_gloss2intensity|Global intensity for specular calculations applied for forced-gloss surfaces, default is 1.}}
+
{{cvar|r_shadow_glossexponent|Global gloss exponent used as a base in shader calculations.}}
+
{{cvar|r_shadow_gloss2exponent|Same one used for forced-gloss surfaces.}}
+
{{cvar|r_shadow_glossexact|Use real reflection math for gloss calculation. This is slower and little more correct.}}
+
 
+
===Shadows===
+
Shadows are most valuable part of realtime lighting. They are increasing scene depth so it looks more realistic. Like with materials, power has a price: shadows are quite complex render task, many lights casting many shadows may decrease rendering speed significantly.
+
 
+
{{important|Map designer should plan his map with this limitation in mind - there should be no situation of many lights being seen from a certain point, or user will experience a game slowdown.}}
+
 
+
Darkplaces supports two realtime shadowing techniques.
+
 
+
====Stencil shadows====
+
[http://en.wikipedia.org/wiki/Shadow_volume Stencil shadow volumes] is a base shadow rendering method Darkplaces.
+
 
+
This technique is well known for it's shadows not having penumbra. Many other restrictions (high fillrate hit, bad scalability) make this method to be used only on a few games (such as Doom 3).
+
 
+
{{cvar|r_shadow_polygonfactor|how much to enlarge shadow volume polygons when rendering (should be 0!)}}
+
{{cvar|r_shadow_polygonoffset|how much to push shadow volumes into the distance when rendering, to reduce chances of zfighting artifacts (should not be less than 0)}}
+
{{cvar|r_shadow_frontsidecasting|whether to cast shadows from illuminated triangles (front side of model) or unlit triangles (back side of model)}}
+
{{cvar|r_showshadows|Show areas covered by shadow volumes. Useful for finding out why some areas of the map render slowly <nowiki>(bright blue = lots of passes, slow)</nowiki>. Only matters if using shadow volumes.}}
+
 
+
====Shadowmapping====
+
Since 2010 [http://en.wikipedia.org/wiki/Shadow_mapping shadow mapping] was implemented by [http://sauerbraten.org/ Eihrul].
+
 
+
Shadowmapping have a number of advantages over shadow volume rendering and is considered to replace it:
+
* Penumbra
+
* Fast to render (especially on complex area maps)
+
* Takes less CPU time (as construction of shadow volumes is not required)
+
* Distance-based LOD (far lights rendered with lower shadowmap resolution)
+
* Shadow edges are not sharp
+
 
+
{{hidden begin|Console variables}}
+
{{cvar|r_shadow_shadowmapping|Enables shadowmapping}}
+
{{cvar|r_shadow_shadowmapping|Shadowmap [[bias]] parameter (this is multiplied by nearclip * 1024 / lodsize}}
+
{{cvar|r_shadow_shadowmapping_bordersize|Shadowmap size bias for filtering}}
+
{{cvar|r_shadow_shadowmapping_depthbits|Requested minimum shadowmap texture depth bits, could be 16 or 24}}
+
{{cvar|r_shadow_shadowmapping_filterquality|Shadowmap filter modes<nowiki>: -1 = auto-select, 0 = no filtering, 1 = bilinear, 2 = bilinear 2x2 blur (fast), 3 = 3x3 blur (moderate), 4 = 4x4 blur (slow)</nowiki>}}
+
{{cvar|r_shadow_shadowmapping_maxsize|Shadowmap size limit}}
+
{{cvar|r_shadow_shadowmapping_minsize|Shadowmap size limit}}
+
{{cvar|r_shadow_shadowmapping_nearclip|Shadowmap near clip in world units. Increasing this will make shadow rendering to be more precise (as more bits goes to middle range), at the cost of the small non-shadowed zone around light}}
+
{{cvar|r_shadow_shadowmapping_polygonfactor|Slope-dependent shadowmapping bias}}
+
{{cvar|r_shadow_shadowmapping_polygonoffset|Constant shadowmapping bias}}
+
{{cvar|r_shadow_shadowmapping_precision|Makes shadowmaps have a maximum resolution of this number of pixels per light source radius unit such that, for example, at precision 0.5 a light with radius 200 will have a maximum resolution of 100 pixels}}
+
{{cvar|r_shadow_shadowmapping_useshadowsampler|whether to use sampler2DShadow if available}}
+
{{cvar|r_shadow_shadowmapping_vsdct|enables use of virtual shadow depth cube texture}}
+
{{cvar|r_usedepthtextures|Use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardwaree.}}
+
{{bug|r_usedepthtextures causing strong precision drop, which leads to splotches around shadow edges}}
+
{{hidden end}}
+
 
+
===Other light models===
+
Darkplaces includes other lighting models which are used eventually:
+
 
+
'''Fake light'''
+
:A developer-only mode which is forced on non-lit maps (ones which was compiled and didnt get LIGHT phase). This is infinite realtime light that is cast from eye position.
+
'''Cel shading'''
+
:Altered shading for default lighting model.
+
'''Lightmap'''
+
:Lightmap with no deluxemap applied (just an old lightmap with no per-pixel lighting effects)
+
'''Fullbright'''
+
:No lighting applied (all textures at their full brightness)
+
 
+
==Light methods==
+
There is 4 lighting methods used in Darkplaces:
+
 
+
* [[Vertex lighting]] - static lighting, aimed at big counts of simple surfaces
+
* [[Lightmap | Lightmaps]] - static lighting, aimed at surfaces that receives shadows from static objects
+
* [[Lightgrid]] - static lighting, aimed at moving entities
+
* Dynamic lighting - full realtime dynamic lighting (each light is a separate pass), aimed at switchable and moving lightsources that lights moving entities
+
 
+
'''Comparison of different lighting methods'''
+
{| width=500 cellspacing=0 cellpadding=2 border=1 style="border-collapse:collapse"
+
! width=40% | Task
+
! width=15% | Vertex<br>lighting
+
! width=15% | Lightmap
+
! width=15% | Lightgrid
+
! width=15% | Realtime lighting
+
|-
+
| Details
+
| <font color=red>Low</font>
+
| <font color=orange>Medium</font>
+
| <font color=red>Low</font>
+
| <font color=green>High</font>
+
|-
+
| Render speed
+
| <font color=green>Fastest</font>
+
| <font color=green>Fast</font>
+
| <font color=green>Fastest</font>
+
| <font color=red>Slow</font>
+
|-
+
| Precomputation time
+
| <font color=green>Short</font>
+
| <font color=red>Long</font>
+
| <font color=orange>Medium</font>
+
| <font color=black>N/A</font>
+
|-
+
| RAM usage
+
| <font color=green>Low</font>
+
| <font color=red>High</font>
+
| <font color=green>Low</font>
+
| <font color=green>Low</font>
+
|-
+
| Shadows
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| Penumbra
+
| <font color=black>N/A</font>
+
| <font color=green>Yes</font>
+
| <font color=black>N/A</font>
+
| <font color=orange>Partial</font>
+
|-
+
| Number of lights
+
| <font color=green>Large</font>
+
| <font color=green>Large</font>
+
| <font color=green>Large</font>
+
| <font color=red>Small</font>
+
|-
+
| colspan=5 | '''Surface-based effects'''
+
|-
+
| Bumpmapping
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
|-
+
| Specular
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
|-
+
| Cubemap filters
+
| <font color=red>No</font>
+
| <font color=orange>Partial</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| Per-light diffuse/ambient/specular scale
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| Non-point 'area' lights
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=red>No</font>
+
|-
+
| Light styles
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| Moving lights
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| colspan=5 | '''Global illumination'''
+
|-
+
| Precomputation time
+
| <font color=orange>Long</font>
+
| <font color=red>Very long</font>
+
| <font color=orange>Long</font>
+
| <font color=black>N/A</font>
+
|-
+
| Rendering speed
+
| <font color=black>N/A</font>
+
| <font color=black>N/A</font>
+
| <font color=black>N/A</font>
+
| <font color=red>Slow</font>
+
|-
+
| Quality
+
| <font color=green>High</font>
+
| <font color=green>High</font>
+
| <font color=green>High</font>
+
| <font color=red>Low</font>
+
|-
+
| colspan=5 | '''Used to light'''
+
|-
+
| Map surfaces
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
|-
+
| Static BModels
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
| <font color=orange>Optional</font>
+
| <font color=green>Yes</font>
+
|-
+
| Moving/rotating BModels
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=orange>Optional</font>
+
| <font color=green>Yes</font>
+
|-
+
| Animated models
+
| <font color=red>No</font>
+
| <font color=red>No</font>
+
| <font color=green>Yes</font>
+
| <font color=green>Yes</font>
+
|}
+
 
+
==Light effects==
+
Darkplaces supports a number of special lighting effects.
+
 
+
===Light styles===
+
Stub!
+
 
+
===Light coronas===
+
Coronas aimed to simulate glow around dynamic lights, which looks good on small and medium size lights. Coronas are customised per-light (size and brightness) an also can be placed without lights.
+
{{cvar|r_coronas|Brightness of corona effects. 0 disables coronas.}}
+
{{cvar|r_coronas_occlusionquery|Fades coronas according to visibility. Bad perormance (synchoronus rendering), even worse on multi-GPU.}}
+
{{cvar|r_coronas_occlusionquerysize|Size of lightsource for corona occlusion checksum. Usial value is 0.1}}
+
 
+
===Light cubemap filtering===
+
A technique for modeling non-uniform light distribution according to direction, for example a lantern may use a cubemap to describe the light emission pattern of the cage around the lantern (as well as soot buildup discoloring the light in certain areas), often also used for softened grate shadows and light shining through a stained glass window (done crudely by texturing the lighting with a cubemap), another good example would be a discolight.
+
 
+
Any dynamic lightsource can have cubemap attached.
+
 
+
===Planar shadows===
+
Simplified global shadows which are cast from entities, not from lights (so planar shadows are just filters, they dont do any lighting math).
+
 
+
Planar shadows are either stencil or shadowmapped if shadowmapping is on.
+
 
+
Blood Omicide using planar shadows to simulate sunlight in outdoor locations.
+
 
+
{{hidden begin|Console variables}}
+
{{cvar|r_shadows|Enable planar shadows cast using [[lightgrid]]-stored light direction. When set to 2 always cast the shadows in the certain direction (see below). Shadowmapping only supports r_shadows 2.}}
+
{{cvar|r_shadows_castfrombmodel|Enables shadows cast from [[BModel | bmodels]].}}
+
{{cvar|r_shadows_darken|How much shadowed areas will be darkened.}}
+
{{cvar|r_shadows_drawafterrtlighting|Hack to draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating sunlight on large outdoor maps with only one big noshadow rtlight. The price is less realistic appearance of dynamic light shadows.}}
+
{{cvar|r_shadows_focus|Offset the shadowed area focus (used for shadowed area bounds).}}
+
{{cvar|r_shadows_shadowmapscale|Increases shadowmap quality (multiply global shadowmap precision). Needs shadowmapping ON.}}
+
{{cvar|r_shadows_throwdirection|r_shadows 2 throwing direction. Default is '0 0 -1' (down).}}
+
{{cvar|r_shadows_throwdistance|How far to cast shadows from models. This sets shadowed area bounds for shadowmapping.}}
+
{{hidden end}}
+
 
+
===Customized modellight===
+
Lightgrid sampling (diffuse, ambient and light vector components) can be overriden by Client Side QuakeC. Allows various lighting effects on models (strobing, using different positions for sampling etc.)
+
 
+
===Fog===
+
Fog are global. Optionally, height plane and height texture can be defined which will make fog to fade with height.
+
 
+
Fog have the following components:
+
 
+
* density - how much fog to add per distance, this is virtual value. 1 means very strong fog.
+
* red - red component of fog color
+
* green - green component of fog color
+
* blue - blue component of fog color
+
* alpha - fog effect opacity (default is 1)
+
* mindist - distance to start applying fog at
+
* maxdist - maximal distance apply fog at
+
* top - origin of height plane at worldspace (game units)
+
* height - fog height fade in game units
+
* fadetexture - horizontal texture that resembles fading, left pixel if top bright, right is top dark. Can be used for non-linear fading.
+
 
+
Fog are set by console commands:
+
{{cmd|fog <nowiki><density> <red> <green> <blue> [<alpha> <mindist> <maxdist> <top> <height>]</nowiki>|Sets the global fog}}
+
{{cmd|fog_heighttexture <nowiki><density> <red> <green> <blue> <alpha> <mindist> <maxdist> <top> <height> <fadetexture></nowiki>|Sets the global fog with customized fade texture}}
+
 
+
== Tweaking ==
+
Darkplaces lighting renderer have a bunch of misc options to tweak.
+
=== Optimizations ===
+
For best performance, all optimisations should be on.
+
 
+
{{cvar|r_shadow_scissor|Use scissor optimization of light rendering (restricts rendering to the portion of the screen affected by the light)}}
+
{{cvar|r_shadow_sortsurfaces|Improve performance by sorting illuminated surfaces by texture}}
+
{{cvar|r_shadow_usebihculling|Use [[BIH | Bounding Interval Hierarchy]] for culling lit surfaces instead of [[BSP|Binary Space Partitioning]]}}
+
 
+
===Light attenuation===
+
This console variables change attenuation for all dynamic lights.
+
 
+
{{cvar|r_shadow_lightattenuationdividebias|Controls the speed of light fading, 1 is default linear fade.}}
+
{{cvar|r_shadow_lightattenuationlinearscale|Linear scale applied during attenuation, larger values will make lesser half-light zones}}
+
{{cvar|r_shadow_lightintensityscale|Renders all lights brighter or darker}}
+
{{cvar|r_shadow_lightradiusscale|Renders all world lights larger or smaller}}
+
 
+
== Getting lights on the map ==
+
Engine supports two ways to get lights on the map.
+
 
+
===World lights===
+
Worlds lights are loaded from external .rtlights file supplied with a map (foo.bsp will try to load foo.rtlights). If there are not .rtlights file, engine tries to load lights from a map "light" entities, which often is grude and terrible slow (as "lights" are maked for map compiler LIGHT stage raytracer, not for reatime rendering). So producing a good .rtlights folr is very first step in a process of map creation.
+
 
+
World lights are static, meaning they canot be moved, rotated, altered during a game.
+
 
+
{{tip|Blood Omnicide is using world lights to place lights for a Q3map2 LIGHT phase. So unlike Quake, which should have both "light" entities and .rtlights, Blood Omnicide .rtlights containins all map static lights}}
+
 
+
Each world light can have this parameters:
+
* origin : position
+
* angles : rotation
+
* color : RGB light color
+
* radius : radius of light in game units
+
* corona : corona intensity (0 to disable)
+
* coronasize : size of corona (this is multiplier to light radius)
+
* style : lights style number (see lightstyles above)
+
* shadows: whether to cast shadows from light
+
* cubemap : a path to [[cubemap]] filter texture
+
* ambient : ambient light intensity (ignores shading, makes lighting to be more 'flat')
+
* diffuse : shading light intensity (default is 1)
+
* specular : specular intensity (default is 1)
+
* normalmode : if this flag is set, light will be draws if cvar r_shadow_realtime_world is 0
+
* realtimemode : if this flag is set, light will be draws if cvar r_shadow_realtime_world is 1
+
 
+
Blood Omnicide tips:
+
{{tip|A combination of <nowiki>normalmode = 0, realtimemode = 0</nowiki> to mark lights which are only appear on lightmap}}
+
{{tip|Light style 1 will make a dynamic lights that will not appear on lightmap}}
+
{{tip|Cubemap-filtered lights dont appear on lightmap}}
+
 
+
Console variables:
+
{{cvar|r_shadow_realtime_world|Enables rendering of full world lighting (whether loaded from the map, or a .rtlights file, or a .ent file, or a .lights file produced by hlight)}}
+
{{cvar|r_shadow_realtime_world_lightmaps|Brightness to render lightmaps when using full world lighting}}
+
{{cvar|r_shadow_realtime_world_shadows|Enables rendering of shadows from world lights}}
+
{{cvar|r_shadow_realtime_world_compile|Enables compilation of world lights for higher performance rendering (shadow volumes only)}}
+
{{cvar|r_shadow_realtime_world_compileportalculling|Enables portal-based culling optimization during compilation (overrides compilesvbsp)}}
+
{{cvar|r_shadow_realtime_world_compileshadow|Enables compilation of shadows from world lights for higher performance rendering (shadow volumes only)}}
+
{{cvar|r_shadow_realtime_world_compilesvbsp|Enables [[svbsp]] optimization during compilation (slower than compileportalculling but more exact)}}
+
{{tip|In Blood Omnicide, this console varisables are hardcoded since its using a combination of full realtime lightning and lightmaps. Tweak this settings only for debugging purposes or if you want to break something.}}
+
 
+
=== Dynamic lights ===
+
Dynamic lights are cast from entities. This could be both server-side entities such as rockets or client-side entities such as explosions.
+
 
+
{{cvar|r_shadow_realtime_dlight|Enables rendering of dynamic lights such as explosions and rocket light}}
+
{{cvar|r_shadow_realtime_dlight_portalculling|Enables portal optimization on dynamic lights}}
+
{{cvar|r_shadow_realtime_dlight_shadows|Enables rendering of shadows from dynamic lights}}
+
{{cvar|r_shadow_realtime_dlight_svbspculling|Enables svbsp optimization on dynamic lights}}
+
 
+
== Galleries ==
+
=== Per-pixel lighting ===
+
<gallery>
+
File:Darkplaces lightexample flat.jpg|Attenuation-only lighting
+
File:Darkplaces lightexample shadows.jpg|+ Shadows
+
File:Darkplaces lightexample shading.jpg|+ Shading
+
File:Darkplaces lightexample specular.jpg|+ Gloss
+
File:Darkplaces lightexample bouncegrid.jpg|+ BounceGrid
+
</gallery>
+
  
 +
__NOTOC__
 
[[Category:Darkplaces engine]]
 
[[Category:Darkplaces engine]]

Latest revision as of 17:51, 9 August 2012

Map with only lighting applied

Lighting is one of the most important and influential elements in level design. It has the power to make or break the visuals, theme and atmosphere. Lighting is just as important as geometry. Without lighting there is no environment but just a group of 3-dimensional objects. Its purpose goes further than just giving the players the ability to see where they are going.

Darkplaces engine combines several lighting techiques in order to get best performance and best looks. Because of that there is lots of options and tricks. Clever usage of them will help designers to make fast-to-render and well themed maps.

This reference will guide you in the deep dungeon of Darkplaces lighting methods, effects, tricks and quirks.

Important Note

Textures are the base for lighting. Before starting to learn how lighting works, be sure to check out Darkplaces material system as many of it's concepts and features used by lighting too.

[edit] Chapters

  1. Introduction
  2. Lighting model
  3. Special effects
  4. Light sources

[edit] Appendix

[edit] Recommended articles

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox