Shader: "sun"

"sun"

ClassLight
Synopsis A light source emitting light from the Sun (i.e., a very distant source). The position of the sun can be set either directly or via a time of day and date, depending on the specified mode of operation.
Arguments

"mode" Type: LtBitfield
Default:LI_SUN_AUTO_NONE
Range: 3
Hint:-
"altitude" Type: LtFloat
Default:90.0
Range:[ -90, 90 ]
Hint:-
"azimuth" Type: LtFloat
Default:0.0
Range:[ 0, 360 ]
Hint:-
"north" Type: LtVector
Default:(0.0, 1.0, 0.0)
Range: [ -inf, inf ], [ -inf, inf ], [ -inf, inf ]
Hint: [ -1, 1 ], [ -1, 1 ], [ -1, 1 ]
"up" Type: LtVector
Default:(0.0, 0.0, 1.0)
Range: [ -inf, inf ], [ -inf, inf ], [ -inf, inf ]
Hint: [ -1, 1 ], [ -1, 1 ], [ -1, 1 ]
"intensity" Type: LtFloat
Default:1.0
Range:[ 0, inf ]
Hint:-
"colour" Type: LtColour
Default:(1.0, 1.0, 1.0)
Range: [ 0, inf ], [ 0, inf ], [ 0, inf ]
Hint: [ 0, 1 ], [ 0, 1 ], [ 0, 1 ]
"colour temperature" Type: LtFloat
Default:0.0
Range:[ 0, 50000 ]
Hint:[ 150, 50000 ]
"latitude" Type: LtFloat
Default:LI_LATITUDE_LONDON
Range:[ -90, 90 ]
Hint:-
"longitude" Type: LtFloat
Default:LI_LONGITUDE_LONDON
Range:[ -180, 180 ]
Hint:-
"time" Type: LtGenericPtr
Default:NULL
Range:-
Hint:-
"sky type" Type: LtGenericPtr
Default:NULL
Range:-
Hint:-
"shadows" Type: LtBoolean
Default:FALSE
Range:-
Hint:-
"shadow type" Type: LtEnum
Default:LI_SHADOW_TYPE_SOFT
Range: 1, 2
Hint:-
"shadow tolerance" Type: LtFloat
Default:0.0
Range:[ 0, 1 ]
Hint:[ 0, 0.1 ]
"shadow transparency" Type: LtBitfield
Default:LI_TRANS_SHADOW_GLOBAL
Range: 15
Hint:-
"shadow acceleration" Type: LtBitfield
Default:LI_SHADOW_ACC_NONE
Range: 31
Hint:-
"shadow resolution" Type: LtInt32
Default:256
Range:[ 0, 8000 ]
Hint:[ 50, 2048 ]
"shadow quality" Type: LtInt32
Default:4
Range:[ 1, 16 ]
Hint:[ 4, 9 ]
"shadow softness" Type: LtFloat
Default:1.0
Range:[ 0.1, 20 ]
Hint:[ 1, 4 ]
"intensity units" Type: LtEnum
Default:LI_INTENS_UNITS_EMPIRICAL
Range: 0, 5, 6, 8
Hint:-
"scattering" Type: LtBoolean
Default:FALSE
Range:-
Hint:-
Locationlishclas
Description The light emitted is parallel to the vector between the coordinate system origin and a point which is located "altitude" degrees above the horizon in the direction "azimuth". The coordinate system in which "altitude" and "azimuth" are defined is specified by means of "north" and "up" vectors. Values of "azimuth" of 0, 90, 180 and 270 degrees correspond to North, East, South and West respectively.

A value of 90 degrees for the "altitude" argument corresponds to the sun in zenith (i.e., directly overhead).

The colour of sun is determined by "colour" and "colour temperature" arguments. The default "colour temperature" is set to LI_CL_SUNLIGHT (5800 Kelvin).

Further details of what is meant by a colour temperature can be found in the LightWorks manual `Lighting'. The value itself is given as an LtFloat representing a temperature value in Kelvin. A number of standard values are defined as symbols, and the value 0.0, means that the "colour" argument is used instead. Similarly, if the "colour" argument is left at its default value of (1.0, 1.0, 1.0) (white) then it will be ignored and the "colour temperature" argument used to decide the light's colour.

If a non-default value is given for "colour" and a non-zero value is given for "colour temperature", note that the final colour of the light will be calculated by combining the two values.

To learn more about these arguments read `Shader arguments for physically-based lighting' in the `Physically-based Lights' section of `Lighting'.

The intensity of the sunlight is controlled by the mean of the "intensity" parameter. The intensity can be specified in different intensity units by setting "intensity units" to one of the following values:

  • LI_INTEN_UNITS_EMPIRICAL Intensity specified in arbitrary empirical units (the default).

  • LI_INTEN_UNITS_LUX Intensity specified in Lux

  • LI_INTEN_UNITS_KILOLUX Intensity specified in Kilolux

  • LI_INTEN_UNITS_FOOTCANDLE Intensity specified in Footcandle

The sun shader can automatically calculate position of sun and its intensity and colour given position of scene, time and data about atmosphere. You can turn on or off calculation of intensity and colour independently of calculation of position of sun. This can be achieved thanks to parameter "mode". By default, "mode" is set to LI_SUN_AUTO_NONE which means, that values of "azimuth", "altitude", "intensity", "colour" and "colour temperature" are being used explicitly and no automatic calculations are performed. You can use two more values of "mode" to force automated calculations.

The modes are:

  • LI_SUN_AUTO_NONE Parameteres "sky type", "time", "latitude" and "longitude" have no meaning. Position and colour of sun are taken from "altitude", "azimuth", "intensity", "colour", and "colour temperature" parameters.

  • LI_SUN_AUTO_POSITION Position of sun, i.e., "altitude" and "azimuth" are calculated automatically according to "time", "latitude" and "longitude". In this mode "altitude" and "azimuth" are of no importance.

  • LI_SUN_AUTO_INTENSITY Colour and intensity of sun are being calculated automatically according to "sky type", "time" and "altitude". In this mode "intensity", "colour", "colour temperature" and "intensity units" are of no importance.

  • LI_SUN_AUTO_ALL This turns on both position and intensity calculations. Use it to achieve realistic effects. In this case "latitude", "longitude", "time" and "sky type" are used to calculate intensity and position of sun and none of "azimuth", "altitude", "intensity", "colour" and "colour temperature" are meaningful.

Parameters "latitude" and "longitude" define the location of scene. Their values are specified in degrees. For "latitude" positive values define position on the north hemisphere, negative values on the south hemisphere. For "longitude" positive values define position on the east hemisphere, negative values on the west hemisphere. There is a number of latitudes and longitudes for major cities defined in lads/include/li/lishclas.h as LI_LATITUDE_XXX and LI_LONGITUDE_XXX, where XXX is the name of a city (in upper case).

Parameter "sky type" is NULL or pointer to valid LtSkyType object. When NULL default values of rural atmosphere model are set. Check references of LiSunIntensity and LiSunPosition API for further details on how colour and intensity calculations are performed.

Parameter "time" is NULL or pointer to valid LtTimeDate object. When NULL default time of 1st January 2000, 00:00:00 GMT is used. Check references of LiSunIntensity and LiSunPosition API for further details on how position of sun is determined.

Calculations of sun position and its intensity and colour are based on algorithms used in API functions LiSunPosition and LiSunIntensity . You can use these functions to calculate sun altitude, azimuth, intensity and colour and pass these values directly into shader. Result will be the same as if you told shader to calculate it, but this is the way to see what exactly are values shader uses.

Shadows may be turned on for the sun by means of the flag passed as argument "shadows", a value of TRUE being used to turn shadows on. Type of shadows being used is controlled by "shadow type". Default value is set to use shadow map and value of LI_SHADOW_TYPE_HARD forces hard-edged, raytraced shadows to be used. The resolution of the shadow map that is used in the preprocessing of shadows is passed in argument "shadow resolution". Note that shadows can only be displayed if the "shadows" argument is set to TRUE and either ray cast shadows are being used or the shadow maps have been preprocessed.

The quality of the shadows is specified by "shadow quality": a value of 1 corresponds to low quality, and a larger value such as 9 gives higher quality. A value that determines how soft the boundaries of shadows appear is specified in argument "shadow softness". A value of 1.0 gives rise to hard shadow boundaries, and a larger value such as 4.0 causes soft boundaries with penumbrae.

By setting "shadow acceleration" to LI_SHADOW_ACC_MAPS when ray casting is being used to caculate shadows and shadow map exists for the light source hybrid technique to calculate shadows is used. This can significantly ncrease computation speed.

The "shadow tolerance" value is used to modify the shadow map sampling distance. It used to deal with self shadowing artifacts that can be apparent with low resolution, high softness shadows. They usually appear as either grid like patterns of smudges or moire patterns.

A value of 0.0 specifies no effect, a value of 1.0 causes no shadows. Values of around 0.1 to 0.2 are usually sufficient to deal with most artifacts. The value of this parameter should be as small as possible. The reason for this is that large values can cause shadows to disappear from objects close to the object casting the shadow. A value of 1.0 will cause all shadows to vanish. For more details see the Lighting manual.

Argument "shadow transparency" controls casting of coloured shadows when hard shadows are turned on. Default value inherits this feature from global settings. More information on shadows and shadows settings in shaders are available in section `Lights' of Lighting.

In order to see the scattered light when "scattering medium" foreground shader is being used you should set "scattering" parameter to TRUE.

Previous page alphabetically (stlayout)
Next page alphabetically (surfeval)
Index


Copyright © 1990-2005, 2006 LightWork Design Limited. All rights reserved