Skip to content

Commit

Permalink
fix opacity issue in scene graph layer (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhuang01 committed Aug 29, 2019
1 parent 9804352 commit 3734700
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -10,7 +10,7 @@ export default `\
#endif
// Uniforms
// none
uniform float opacity;
// Varying
_varying vec4 vColor;
Expand All @@ -36,6 +36,7 @@ void main(void) {
#endif
#endif
fragmentColor.a *= opacity;
DECKGL_FILTER_COLOR(fragmentColor, geometry);
}
`;
4 changes: 3 additions & 1 deletion modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js
Expand Up @@ -46,6 +46,7 @@ const defaultProps = {
sizeScale: {type: 'number', value: 1, min: 0},
getPosition: {type: 'accessor', value: x => x.position},
getColor: {type: 'accessor', value: DEFAULT_COLOR},
opacity: {type: 'number', min: 0, max: 1, value: 1.0},

// flat or pbr
_lighting: 'flat',
Expand Down Expand Up @@ -248,7 +249,7 @@ export default class ScenegraphLayer extends Layer {
this.state.animator.animate(context.animationProps.time);
}

const {sizeScale, _enableOffsetModelMatrix} = this.props;
const {sizeScale, opacity, _enableOffsetModelMatrix} = this.props;
const numInstances = this.getNumInstances();
this.state.scenegraph.traverse((model, {worldMatrix}) => {
model.model.setInstanceCount(numInstances);
Expand All @@ -257,6 +258,7 @@ export default class ScenegraphLayer extends Layer {
parameters,
uniforms: {
sizeScale,
opacity,
enableOffsetModelMatrix: _enableOffsetModelMatrix,
sceneModelMatrix: worldMatrix,
// Needed for PBR (TODO: find better way to get it)
Expand Down

0 comments on commit 3734700

Please sign in to comment.