User Tools

Site Tools


gamedev:lighting

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.

Sky Lights

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.

Particle Lights

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.

Texture Emissivity

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

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:

Light Type

Defines the type of the light. These types are supported:

Point

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

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

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.

Light Color

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.

Intensity

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:

  • Moon light of full moon: 0.01
  • Candle in a dark room: 0.1
  • Living room lit at night: 1
  • Bright lit office room: 2-4
  • Overcast day light: 10
  • Clear sky day light: 20

Range

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.

Half Intensity Distance

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.

Ambient Ratio

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.

Orientation

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.

Spot Angle

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.

Spot Ratio

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.

Spot Smoothness

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.

Spot Exponent

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.

Light Shape

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.

Light Skin

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).

Light Canvas

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.

Dynamic Skin

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.

Transform

Defines the texture coordinate transformation to use. This is used for light canvas property only. For light skin transformation use Dynamic Skin instead.

Hint Light Importance

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.

Hint Shadow Importance

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.

Hint Movement

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:

  • Stationary: Light remains static for the entire lifetime.
  • Jittering: Light remains mostly static jittering in a small area.
  • Dynamic: Light moves around freely.

Hint Parameter

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:

  • Static: Light parameters never change.
  • Activation: Light parameters never change except activation (switching light on and off).
  • Flicker: Geometric light parameters never change but others can like intensity. All properties affecting the range of the light (like range or spot angle) count as geometric light poarameters since the typically force a Graphic Module to update optimization structures. All other properties only affecting the shape and color of the light inside the outer boundary are not considered geometric light parameters since they typically do not require updating optimization structures.
  • Dynamic: All light parameters can change at any time.

Layer Mask

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.

Shadow Layer Mask

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.

Activated

Defines if the light is shining.

Cast Shadows

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.

Ignore Components List

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.

You could leave a comment if you were logged in.
gamedev/lighting.txt · Last modified: 2020/10/27 18:17 by dragonlord