Creates a ShadowGenerator object. A ShadowGenerator is the required tool to use the shadows. Each light casting shadows needs to use its own ShadowGenerator. Documentation : http://doc.babylonjs.com/tutorials/shadows
The size of the texture what stores the shadows. Example : 1024.
The light object generating the shadows.
By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
Sets the bias: offset applied on the depth preventing acnea (in light direction).
Sets the blur box offset: offset applied during the blur pass. Only usefull if useKernelBlur = false
Sets the blur kernel: kernel size of the blur pass. Only usefull if useKernelBlur = true
Sets the blur scale: scale of the blurred texture compared to the main shadow map. 2 means half of the size.
Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size. Using a ratio helps keeping shape stability independently of the map size.
It does not account for the light projection as it was having too much instability during the light setup or during light position changes.
Only valid if useContactHardeningShadow is true.
Sets the depth scale used in ESM mode. This can override the scale stored on the light.
Sets the current mode of the shadow generator (normal, PCF, ESM...). The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
Sets the PCF or PCSS Quality. Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
If true the shadow map is generated by rendering the back face of the mesh instead of the front face. This can help with self-shadowing as the geometry making up the back of objects is slightly offset. It might on the other hand introduce peter panning.
Controls the extent to which the shadows fade out at the edge of the frustum Used only by directionals and spots
Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
Sets the current filter to filtered "close ESM" (using the inverse of the exponential to prevent steep falloff artifacts).
Gets if the current filter is set to filtered ESM.
Sets the current filter is to blurred VSM. DEPRECATED. Should use useBlurExponentialShadowMap instead.
Sets the current filter to "close ESM" (using the inverse of the exponential to prevent steep falloff artifacts).
Sets the current filter to "PCSS" (contact hardening).
Sets the current filter is to ESM.
Sets whether the blur pass is a kernel blur (if true) or box blur. Only usefull in filtered mode (useBlurExponentialShadowMap...)
Sets the current filter to "PCF" (percentage closer filtering).
Sets the current filter to Poisson Sampling.
Sets the current filter is to VSM. DEPRECATED. Should use useExponentialShadowMap instead.
Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing edge artifacts on steep falloff. (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
Shadow generator mode ESM: Blurred Exponential Shadow Mapping. (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing edge artifacts on steep falloff. (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
Shadow generator mode ESM: Exponential Shadow Mapping. (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
Shadow generator mode None: no filtering applied.
Shadow generator mode PCF: Percentage Closer Filtering benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1 (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
Shadow generator mode PCSS: Percentage Closering Soft Shadow. benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1 Contact Hardening
Shadow generator mode Poisson Sampling: Percentage Closer Filtering. (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
Reserved for PCF and PCSS Highest Quality.
Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
Execute PCSS with 32 taps blocker search and 64 taps PCF.
Reserved for PCF and PCSS The lowest quality but the fastest.
Execute PCF on a 1*1 kernel.
Execute PCSS with 16 taps blocker search and 16 taps PCF.
Reserved for PCF and PCSS Good tradeoff for quality/perf cross devices
Execute PCF on a 3*3 kernel.
Execute PCSS with 16 taps blocker search and 32 taps PCF.
Helper function to add a mesh and its descendants to the list of shadow casters.
Mesh to add
boolean indicating if the descendants should be added. Default to true
the Shadow Generator itself
Binds the shadow related information inside of an effect (information like near, far, darkness... defined in the generator but impacting the effect).
Index of the light in the enabled light list of the material owning the effect
The effect we are binfing the information for
Disposes the ShadowGenerator. Returns nothing.
Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
Callback triggered at the and of the effects compilation
Sets of optional options forcing the compilation with different modes
Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
Sets of optional options forcing the compilation with different modes
A promise that resolves when the compilation completes
Returns the darkness value (float). This can only decrease the actual darkness of a shadow. 0 means strongest and 1 would means no shadow.
the darkness.
Returns the associated light object.
the light generating the shadow
Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
The render target texture if present otherwise, null
Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
The render target texture if the shadow map is present otherwise, null
Gets the transformation matrix used to project the meshes into the map from the light point of view. (eq to shadow prjection matrix * light transform matrix)
The transform matrix used to create the shadow map
Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
The submesh we want to render in the shadow map
Defines wether will draw in the map using instances
true if ready otherwise, false
Prepare all the defines in a material relying on a shadow map at the specified light index.
Defines of the material we want to update
Index of the light in the enabled light list of the material
Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between Cube and 2D textures for instance.
Helper function to remove a mesh and its descendants from the list of shadow casters
Mesh to remove
boolean indicating if the descendants should be removed. Default to true
the Shadow Generator itself
Serializes the shadow generator setup to a json object.
The serialized JSON object
Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
The darkness value 0 means strongest and 1 would means no shadow.
the shadow generator allowing fluent coding.
Sets the ability to have transparent shadow (boolean).
True if transparent else False
the shadow generator allowing fluent coding
Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
The JSON object to parse
The scene to create the shadow map for
The parsed shadow generator
Generated using TypeDoc
Default implementation IShadowGenerator. This is the main object responsible of generating shadows in the framework. Documentation: https://doc.babylonjs.com/babylon101/shadows