Class LightManager.ShadowOptions
- java.lang.Object
-
- com.google.android.filament.LightManager.ShadowOptions
-
- Enclosing class:
- LightManager
public static class LightManager.ShadowOptions extends java.lang.ObjectControl the quality / performance of the shadow map associated to this light
-
-
Field Summary
Fields Modifier and Type Field Description floatblurWidthBlur width for the VSM blur.float[]cascadeSplitPositionsThe split positions for shadow cascades.floatconstantBiasConstant bias in world units (e.g.intmapSizeSize of the shadow map in texels.floatmaxShadowDistanceMaximum shadow-occluder distance for screen-space contact shadows (world units).floatnormalBiasAmount by which the maximum sampling error is scaled.booleanscreenSpaceContactShadowsWhether screen-space contact shadows are used.floatshadowBulbRadiusLight bulb radius used for soft shadows.intshadowCascadesNumber of shadow cascades to use for this light.floatshadowFarDistance from the camera after which shadows are clipped.floatshadowFarHintOptimize the quality of shadows in front of this distance from the camera.floatshadowNearHintOptimize the quality of shadows from this distance from the camera.booleanstableControls whether the shadow map should be optimized for resolution or stability.intstepCountNumber of ray-marching steps for screen-space contact shadows (8 by default).intvsmMsaaSamplesThe number of MSAA samples to use when rendering VSM shadow maps.
-
Constructor Summary
Constructors Constructor Description ShadowOptions()
-
-
-
Field Detail
-
mapSize
public int mapSize
Size of the shadow map in texels. Must be a power-of-two and larger or equal to 8.
-
shadowCascades
@IntRange(from=1L, to=4L) public int shadowCascadesNumber of shadow cascades to use for this light. Must be between 1 and 4 (inclusive). A value greater than 1 turns on cascaded shadow mapping (CSM). Only applicable to Type.SUN or Type.DIRECTIONAL lights.When using shadow cascades,
cascadeSplitPositionsmust also be set.- See Also:
cascadeSplitPositions
-
cascadeSplitPositions
@NonNull @Size(min=3L) public float[] cascadeSplitPositions
The split positions for shadow cascades.Cascaded shadow mapping (CSM) partitions the camera frustum into cascades. These values determine the planes along the camera's Z axis to split the frustum. The camera near plane is represented by 0.0f and the far plane represented by 1.0f.
For example, if using 4 cascades, these values would set a uniform split scheme: { 0.25f, 0.50f, 0.75f }
For N cascades, N - 1 split positions will be read from this array.
Filament provides utility methods inside
LightManager.ShadowCascadesto help set these values. For example, to use a uniform split scheme:LightManager.ShadowCascades.computeUniformSplits(options.cascadeSplitPositions, 4);
-
constantBias
public float constantBias
Constant bias in world units (e.g. meters) by which shadows are moved away from the light. 1mm by default. This is ignored when the View's ShadowType is set to VSM.
-
normalBias
public float normalBias
Amount by which the maximum sampling error is scaled. The resulting value is used to move the shadow away from the fragment normal. Should be 1.0. This is ignored when the View's ShadowType is set to VSM.
-
shadowFar
public float shadowFar
Distance from the camera after which shadows are clipped. This is used to clip shadows that are too far and wouldn't contribute to the scene much, improving performance and quality. This value is always positive. Use 0.0f to use the camera far distance.
-
shadowNearHint
public float shadowNearHint
Optimize the quality of shadows from this distance from the camera. Shadows will be rendered in front of this distance, but the quality may not be optimal. This value is always positive. Use 0.0f to use the camera near distance. The default of 1m works well with many scenes. The quality of shadows may drop rapidly when this value decreases.
-
shadowFarHint
public float shadowFarHint
Optimize the quality of shadows in front of this distance from the camera. Shadows will be rendered behind this distance, but the quality may not be optimal. This value is always positive. Use std::numerical_limits::infinity() to use the camera far distance.
-
stable
public boolean stable
Controls whether the shadow map should be optimized for resolution or stability. When set to true, all resolution enhancing features that can affect stability are disabling, resulting in significantly lower resolution shadows, albeit stable ones.
-
screenSpaceContactShadows
public boolean screenSpaceContactShadows
Whether screen-space contact shadows are used. This applies regardless of whether a Renderable is a shadow caster. Screen-space contact shadows are typically useful in large scenes. (off by default)
-
stepCount
public int stepCount
Number of ray-marching steps for screen-space contact shadows (8 by default).CAUTION: this parameter is ignored for all lights except the directional/sun light, all other lights use the same value set for the directional/sun light.
-
maxShadowDistance
public float maxShadowDistance
Maximum shadow-occluder distance for screen-space contact shadows (world units). (30 cm by default)CAUTION: this parameter is ignored for all lights except the directional/sun light, all other lights use the same value set for the directional/sun light.
-
vsmMsaaSamples
@IntRange(from=1L) public int vsmMsaaSamples
The number of MSAA samples to use when rendering VSM shadow maps. Must be a power-of-two and greater than or equal to 1. A value of 1 effectively turns off MSAA. Higher values may not be available depending on the underlying hardware.Warning: This API is still experimental and subject to change.
-
blurWidth
public float blurWidth
Blur width for the VSM blur. Zero do disable. The maximum value is 125.
-
shadowBulbRadius
public float shadowBulbRadius
Light bulb radius used for soft shadows. Currently this is only used when DPCF is enabled. (2cm by default).
-
-