Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadow effect RFC #3350

Merged
merged 8 commits into from Jul 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 68 additions & 0 deletions dev-docs/RFCs/v7.x/shadow-for-directional-lights.md
@@ -0,0 +1,68 @@
# RFC: Shadow for directional lights

* **Authors**: Jian Huang

* **Date**: July. 2019

* **Status**: For Review

## Abstract
Deck.gl has new basic lighting effect since 7.0, having shadow effects for directional lights can improve rendering quality.

## Proposal
### API
`LightWithShadowEffect` class is the public interface to create shadow effects, it extends from `LightingEffect` and has one param.
* `lights`(Object): collection of light sources

New layer prop
* `enableShadow`(Boolean): when this prop is true, layer casts and renders shadows
jianhuang01 marked this conversation as resolved.
Show resolved Hide resolved

### Example
```js
const 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]
});

const dirLight1 = new DirectionalLight({
color: [255, 255, 255],
intensity: 1.0,
direction: [-10, -20, -30]
});

const lightWithShadowEffect = new LightWithShadowEffect({
ambientLight,
dirLight0,
dirLight1
});
const deckgl = new Deck({
canvas: 'my-deck-canvas',
effects: [lightWithShadowEffect],
layers: [
// building layer
new SolidPolygonLayer({
enableShadow: true,
...
}),
// ground layer
new SolidPolygonLayer({
enableShadow: true,
...
})
]
});
```
### Workflow
* User creates `LightWithShadowEffect` instance which adds shadow modules into default shader modules
* `LightWithShadowEffect` 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 supported
* For each shadow pass, layers are rendered to a shadow map
* After all the effects are processed, there is a regular layer rendering pass, shadow maps are used to render the final shadows.

## Limitations
With the current design, the user needs to create `LightWithShadowEffect` instance before Deck's initialization, so that the default modules can be modified before layer shaders are assembled.