ShadowSettings

Classes

ShadowSettings : NativeComponent

This component is used to setup shadows. Shadows implemented with CSM technic(Cascaded Shadow Maps). It is a method of rendering shadows that allows for high-quality shadows with minimal performance impact. It works by rendering the scene from the light’s point of view multiple times, each time with a different camera frustum. The resulting shadow map is then used to render shadows in the scene.

To see CSM in editor: Top game panel -> display -> Cascade Shadow Maps

For more information about CSM see https://learn.microsoft.com/en-us/windows/win32/dxtecharts/cascaded-shadow-maps

To use this component, add the following line to your project file:

require engine.core_components.shadow_settings_component // or require engine.core

Usage example:

let setting = create_render_settings()
// Set up shadows for small scene
get_component(renderSettings) $(var shadows : ShadowSettings?) {
    shadows.shadowStrength = 0.5 // reduce shadow impact
    shadows.numCascades = 1 // use only one cascade because our scene is too small
    shadows.maxDist = 25f // set maximal distance for shadows to 25 meters, it is enough for our scene
}
Properties:

ShadowSettings.active: bool
ShadowSettings.active =(value: bool)

Active flag. If set to true, shadows render enabling. Default is true.

Arguments:
  • value : bool

ShadowSettings.shadowStrength: float
ShadowSettings.shadowStrength =(value: float)

Strength of the shadow. If less 1 reduce shadow impact, if equals to 0 result the same as no shadows at all. It isn’t physical correct, but can be used for more nice picture. Default is 1.0.

Arguments:
  • value : float

ShadowSettings.cascadeDepthHighPrecision: bool
ShadowSettings.cascadeDepthHighPrecision =(value: bool)

Use high precision texture format for shadow render. If set to true increase memory consuming and reduce performance of shadows rendering and sampling. Default is false.

Arguments:
  • value : bool

ShadowSettings.numCascades: int
ShadowSettings.numCascades =(value: int)

Number of shadow cascades. Each cascade has performance impact. Default is 2.

Arguments:
  • value : int

ShadowSettings.cascadeWidth: int
ShadowSettings.cascadeWidth =(value: int)

Resolution of each cascade in pixels. Than resolution is higher than more smooth shadows you can see, but it increase timing for shadow rendering. Default is 1024.

Arguments:
  • value : int

ShadowSettings.powWeight: float
ShadowSettings.powWeight =(value: float)

Tweak this parameter closer to 1 to make near cascades smaller relative to far cascade. Default is 0.5.

Arguments:
  • value : float

ShadowSettings.maxDist: float
ShadowSettings.maxDist =(value: float)

Maximal distance for shadow. Out this distance will be no shadows. Default is 50 meters.

Arguments:
  • value : float

ShadowSettings.shadowStart: float
ShadowSettings.shadowStart =(value: float)

Offset for shadow rendering. It can increase quality of shadows in case when there is no objects near with camera. Default is 0.0.

Arguments:
  • value : float