CLASSES
TagsA - Z

ShadowGenerator

Description

class ShadowGenerator

Shadows are dynamic, they are dynamically generated depending upon a Directionallight.

A tutorial about shadows can be found here : https://doc.babylonjs.com/tutorials/shadows

Constructor

new ShadowGenerator(mapSize, light)

Creates a ShadowGenerator object.

A ShadowGenerator is the required tool to use the shadows.

Each light casting shadows needs to use its own ShadowGenerator.

Required parameters :

Documentation : http://doc.babylonjs.com/tutorials/shadows

Parameters

Name Type Description
mapSize number The size of the shadow map
light IShadowLight The light used for the shadow map's computation

Members

static FILTER_NONE : number

No filter will be used for this shadow

static FILTER_POISSONSAMPLING : number

The poisson sampling filter will be used

static FILTER_EXPONENTIALSHADOWMAP : number

static FILTER_BLUREXPONENTIALSHADOWMAP : number

blurScale : number

forceBackFacesOnly : boolean

bias : number

blurBoxOffset : number

depthScale : number

filter : number

One of the following values : FILTER_NONE, FILTER_VARIANCESHADOWMAP, FILTER_POISSONSAMPLING

useVarianceShadowMap : boolean

True by default, defines the realtime shadowing algorithm, using the light's point of view

useExponentialShadowMap : boolean

usePoissonSampling : boolean

Disables the useVarianceShadowMap and activates poisson sampling to soften shadows

useBlurVarianceShadowMap : boolean

useBlurExponentialShadowMap : boolean

Methods

recreateShadowMap() void

isReady(subMesh, useInstances) boolean

Boolean : true when the ShadowGenerator is finally computed.

Parameters

Name Type Description
subMesh SubMesh @param subMesh
useInstances boolean @param useInstances

getShadowMap() RenderTargetTexture

Returns a RenderTargetTexture object : the shadow map texture.

getShadowMapForRendering() RenderTargetTexture

Returns the most ready computed shadow map as a RenderTargetTexture object.

getLight() IShadowLight

Returns the associated light object.

getTransformMatrix() Matrix

Returns a Matrix object : the updated transformation matrix.

getDarkness() number

Returns the darkness value (float).

setDarkness(darkness) ShadowGenerator

Sets the ShadowGenerator darkness value (float <= 1.0).

Returns the ShadowGenerator.

Parameters

Name Type Description
darkness number The given darkness

setTransparencyShadow(hasShadow) ShadowGenerator

Sets the ability to have transparent shadow (boolean).

Returns the ShadowGenerator.

Parameters

Name Type Description
hasShadow boolean default : false. True to activate transparency shadow, else false

dispose() void

Disposes the ShadowGenerator.

Returns nothing.

serialize() any

Serializes the ShadowGenerator and returns a serializationObject.

static Parse(parsedShadowGenerator, scene) ShadowGenerator

Parses a serialized ShadowGenerator and returns a new ShadowGenerator.

Parameters

Name Type Description
parsedShadowGenerator any
scene Scene

prepareDefines(defines, lightIndex) void

This creates the defines related to the standard BJS materials.

Parameters

Name Type Description
defines MaterialDefines
lightIndex number

bindShadowLight(lightIndex, effect, depthValuesAlreadySet) boolean

This binds shadow lights related to the standard BJS materials.

It implies the unifroms available on the materials are the standard BJS ones.

Parameters

Name Type Description
lightIndex string
effect Effect
depthValuesAlreadySet boolean