Start Page » Game Development with the Drag[en]gine » Lighting System
Lighting works according to the principles of Physically based Rendering and thus using high dynamic range rendering (HDRR).
The intensity value relates to real world light intensities not in a 1-to-1 scale but more in a rescale scale mapping a well lit room to the value 1 for convenience. An intensity value of 1 thus equals roughly a 100W light bulb or a well lit room at night. 10 equals roughly an overcast day outside. 20 equals roughly a full bright sunny day out in plain sun.
There exist different light sources that can be used.
Skies support lights to be defined for each layer. Multiple sky lights can be used like this providing outdoor lighting from the sun or other weather phenomena. Details about working with sky lights can be found here: Sky Layers.
Particles cast by particle emitters can emit omni-directional lights. Each particle is comparable to a point light source with short range. In particular the emissivity particle parameter influences the intensity of the light and the color particle parameters the color of the light. The Graphic Module is free to choose the remaining lighting parameters to create good looking particle lights. Details about particle emitters can be found here: Emitters.
Textures can emit light too. Such textures can be used on various world elements like components, billboards, decals and particle emitters. As with particles the Graphic Module defines the light parameters except intensity and color. Details about texture emissivity can be found here: Skin Texture Properties, in particular the texture properties:
Light resources are the typical way to add lights to a game world besides the sky light. Any number of light sources can be added to a game world. Light sources can be (de-)activated which allows to switch them on and off without adding/removing them from the game world all the time. Light sources can be of type point, spot or projector. Most of the properties apply to all light type but some only to spot and projector lights. These are the properties:
Defines the type of the light. These types are supported:
Point lights emit light in all directions equally. They are simple to use but often more expensive than spot or projector lights especially for shadow casting.
Spot lights emit light in a cone shape. The cone is oriented along the Z-Axis of the light resource. The various spot parameters define the shape of the light along the cone.
Projector lights work similar to spot lights but have a pyramidal shape. This allows to have rectangular shaped lights whereas spot lights are cone shaped. The same spot parameters affect the projector lights but angles define the width and height of the pyramid instead.
Defines the color of the light as RGB value (red, green, blue). The color is defined with a gamma of 2.2 . To set linear color apply gamma of 2.2 yourself. Color components are in the range from 0 to 1.
Defines the intensity of the light. The intensity value relates to real world light intensities not in a 1-to-1 scale but more in a rescale scale mapping a well lit room to the value 1 for convenience. An intensity value of 1 thus equals roughly a 100W light bulb or a well lit room at night. 10 equals roughly an overcast day outside. 20 equals roughly a full bright sunny day out in plain sun. You can use these values as references:
Defines the range of the light in meters. Physically light has no range it can only become infinitesimally weak. For performance reasons and to allow better light control lights in the Drag[en]gine have a range limit beyond which their intensity is 0.
Defines the relative distance as percentage value (range 0 to 1) along the range of the light source where the light intensity drops to 50% of the full light intensity. This parameter allows to shape the light attenuation along the light range. A value of 0.1 represent natural light attenuation obeying the square-distance attenuation law. Values larger than 0.1 brighten the light causing a stronger drop near the range limit. Values less than 0.1 attenuate the light stronger.
Defines the amount of intensity affecting objects in shadow. Using ambient intensity larger than 0 allows to simulate overhead lights in rooms without needing multiple light sources to cancel out pitch black areas. Using fewer light sources is faster. The ambient ratio can be set in the range from 0 to 1. Increasing the ambient ratio only affects shadow areas. The light intensity is not altered.
Light sources are oriented by nature. For spot and projector type light sources the orientation defines the direction of the light cone/pyramid which lies along the Z-Axis. For point type light sources the orientation has no effect until a light skin is set. In this situation the light skin is orientated with the top pole along the Y-Axis.
For spot type light sources this parameter defines the outer angle of the light cone in degrees. Outside the spot angle the light has 0 intensity.
For projector type light sources this parameter defines the width and height of the of the projector image in degrees. Outside the projection area the light as 0 intensity.
For point type light sources this parameter is ignored.
For projector type light sources this parameter defines the ratio between the projection height and width (hence spotRatio = height/width). This allows to change the projector image shape from a square shape into various rectangular shapes. The ratio value can be any value larger than 0. Values less than 1 create projection images which are wider than tall while values larger than 1 crate projection images which are taller than wide.
For spot and point type light sources this parameter is ignored.
For spot and projector type light sources this defines the blending between the outer area and the center of the light cone/pyrmaid. The value is a percentage value in the range from 0 to 1. A value of 0 keeps intensity at full intensity abruptly falling to 0 at the outer boundary. A value of 1 creates a smooth blend from the center of the light cone/pyramid to the outer border.
For point type light sources this parameter is ignored.
For spot and projector type light sources this defines the shape of the blending between the center of the light cone/pyramid and the outer border. A value of 1 blends linearly. Values larger than 1 keep the light brighter along the cone/pyramid dropping faster near the border. Values less than 1 create the opposite effect. A value of 2 is comparable to quadratic blending. A value of of 3 is comparable to cubic blending.
For point type light sources this parameter is ignored.
Defines an analytic shape limiting the light area. This can be used to improve performance by telling the Graphic Module that the light source can never reach outside the light shape.
Defines a skin file to use as light image. Light images allow defining complex light shapes and optionally tinting. A typical use for light images is to apply real world measured luminaire shapes (for example IES Light Profiles) or projecting images into the game world.
The image pixels are multiplied with the attenuation and light shaping already defined by the light source (not replacing it). This applies especially to spot and projected type light sources where the spot parameters shape the light attenuation along the cone/pyramid.
For point type light sources the skin is required to have one omni-directional texture using color.omnidir or color.omnidir.equirect texture property. This allows using either a cube map type image (image with depth 6) or an equirectangular type image (360×180 degrees map).
For spot and projector type light sources the skin is required to have one texture using color texture property. The image is stretched to fill the entire outer area boundary. For projector type light sources this fills the entire light area. For spot type light sources to fills the circular area fitting tight against the image boundaries. You are thus loosing the outer corners of the image.
For spot and projector type light sources it is also possible to use omni-directional textures as with point type light sources. In this situation the Z-Axis direction of the omni-directional light skin is lined up with the Z-Axis direction of the light source (spot cone/pyramid). Depending on the light image used it is required to rotate the light image first to make a different axis line up with the light source Z-Axis (see omnidir.rotate).
Defines a Canvas View to use as source of the light image instead of a light skin. This allows creating dynamic light content for example to create projectors with content manipulated by game scripts.
Defines a Dynamic Skin resource to use to manipulate light skin parameters at runtime. Typical use for dynamic skins is to apply dynamic tinting of light skins or manipulating the texture coordinate transformation to create animated content without needing to use a Canvas View.
Defines the texture coordinate transformation to use. This is used for light canvas property only. For light skin transformation use Dynamic Skin instead.
Tells the Graphic Module how important this light is for the game in the range 0 to 100. The Graphic Module can use this value to optimize lighting if the user hardware is limited. A value of 100 indicates very important lights which should be always rendered at the best quality possible. A value of 0 indicates unimportant lights where potential optimizations have marginal effect. The default value is 100. This is only a hint.
Tells the Graphic Module how important shadow casting is for the game in the range 0 to 100. The Graphic Module can use this value to optimize shadow casting if the user hardware is limited. A value of 100 indicates very important lights which should always cast good quality shadows. A value of 0 indicates unimportant lights where potential optimizations have marginal effect. The default value is 100. This is only a hint.
Tells the Graphic Module how the game intents to move the light. Using this hint the Graphic Module can optimize the light handling. These values are supported:
Tells the Graphic Module how the game intents to alter parameters of the light. Using this hint the Graphic Module can optimize the light handling. These values are supported:
Defines the layer mask to use to light world elements. For cameras to show the light the camera Layer Mask has to match the light Layer Mask. For environment maps to show the light the environment map Layer Mask has to match the light Layer Mask. Other world elements like components are lit if they are visible by the camera.
Defines the layer mask to use to include world elements in shadow casting. Components only cast shadows by this light if their Layer Mask matches the light shadow layer mask.
Defines if the light is shining.
Defines if the light is casting shadows. Disabling shadow casting allows to create ambient lights (filler lights). Shadow casting is an expensive process with some Graphic Modules more than others. Disabling shadow casting for lights not necessarily needing it the overall performance of the game is usually increased.
Components can be individually added to the ignore list for each light. All components in the ignore list are not causing shadow casting but are still lit. This is typically used for lights attached to components where the component itself should cast shadows only by any other light source but not the one attached to it.