dev-docs/RFCs/v7.2/shadow-for-directional-lights.md
Authors: Jian Huang
Date: July. 2019
Status: Approved
Deck.gl has new basic lighting effect since 7.0, having shadow effects for directional lights can improve rendering quality.
DirectionalLight class is the public interface to create shadow effects
_shadow(Boolean): create shadow effect when set to true, default is falseNew layer prop
shadowEnabled(Boolean): when this prop is true, layer casts and renders shadowsconst ambientLight = new AmbientLight({
color: [255, 255, 255],
intensity: 1.0
});
const dirLight0 = new DirectionalLight({
color: [255, 255, 255],
intensity: 1.0,
direction: [10, -20, -30],
_shadow: true
});
const dirLight1 = new DirectionalLight({
color: [255, 255, 255],
intensity: 1.0,
direction: [-10, -20, -30],
_shadow: true
});
const lightingEffect = new LightingEffect({
ambientLight,
dirLight0,
dirLight1
});
const deckgl = new Deck({
canvas: 'my-deck-canvas',
effects: [lightingEffect],
layers: [
// building layer
new SolidPolygonLayer({
shadowEnabled: true,
...
}),
// ground layer
new SolidPolygonLayer({
shadowEnabled: true,
...
})
]
});
LightingEffect instance which adds shadow modules into default shader modulesLightingEffect instance is passed into deck and create shadow passes based on light directions, there is one shadow pass for each directional light, for now totally two lights are supportedWith the current design, the user needs to create LightingEffect instance before Deck's initialization, so that the default modules can be modified before layer shaders are assembled.