Skip to content

Commit

Permalink
Merge 9e68962 into 6aeb983
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Jul 11, 2019
2 parents 6aeb983 + 9e68962 commit ee6d200
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 15 deletions.
15 changes: 15 additions & 0 deletions docs/api-reference/layer.md
Expand Up @@ -288,6 +288,21 @@ And is expected to return an array of "ranges", in the form of `{startRow, endRo

**This feature is experimental and intended for advanced use cases.** Note that it only rewrites part of a buffer, not remove or insert, therefore the user of this prop is responsible of making sure that all the unchanged objects remain at the same indices between `oldData` and `newData`. This becomes trickier when dealing with data of dynamic lengths, for example `PathLayer`, `PolygonLayer` and `GeoJsonLayer`. Generally speaking, it is not recommended to use this feature when the count of vertices in the paths/polygons may change.

##### `positionFormat` (String, optional)

One of `'XYZ'`, `'XY'`.

This prop is currently only effective in `PathLayer`, `SolidPolygonLayer` and `PolygonLayer`.

Default `'XYZ'`.

##### `colorFormat` (String, optional)

One of `'RGBA'`, `'RGB'`.

Setting it to `'RGB'` will make the layer ignore the alpha channel and assume `a: 255`.

Default `'RGBA'`.

##### `numInstances` (Number, optional)

Expand Down
7 changes: 7 additions & 0 deletions modules/core/src/lib/layer.js
Expand Up @@ -74,6 +74,8 @@ const defaultProps = {
coordinateOrigin: {type: 'array', value: [0, 0, 0], compare: true},
modelMatrix: {type: 'array', value: null, compare: true, optional: true},
wrapLongitude: false,
positionFormat: 'XYZ',
colorFormat: 'RGBA',

parameters: {},
uniforms: {},
Expand Down Expand Up @@ -299,6 +301,11 @@ export default class Layer extends Component {
for (const extension of this.props.extensions) {
shaders = mergeShaders(shaders, extension.getShaders.call(this, extension));
}
if (this.props.colorFormat === 'RGB') {
shaders = mergeShaders(shaders, {
defines: {COLOR_FORMAT_RGB: 1}
});
}
return shaders;
}

Expand Down
10 changes: 10 additions & 0 deletions modules/core/src/shaderlib/index.js
Expand Up @@ -40,6 +40,16 @@ export function initializeShaderModules() {
createShaderHook('vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)');
createShaderHook('fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)');

createModuleInjection('geometry', {
hook: 'vs:DECKGL_FILTER_COLOR',
order: 99,
injection: `
#ifdef COLOR_FORMAT_RGB
color.a *= 255.;
#endif
`
});

createModuleInjection('picking', {
hook: 'fs:DECKGL_FILTER_COLOR',
order: 99,
Expand Down
4 changes: 2 additions & 2 deletions modules/layers/src/arc-layer/arc-layer.js
Expand Up @@ -68,14 +68,14 @@ export default class ArcLayer extends Layer {
update: this.calculateInstancePositions64Low
},
instanceSourceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getSourceColor',
defaultValue: DEFAULT_COLOR
},
instanceTargetColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getTargetColor',
Expand Down
4 changes: 2 additions & 2 deletions modules/layers/src/column-layer/column-layer.js
Expand Up @@ -86,14 +86,14 @@ export default class ColumnLayer extends Layer {
update: this.calculateInstancePositions64xyLow
},
instanceFillColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getFillColor',
defaultValue: DEFAULT_COLOR
},
instanceLineColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getLineColor',
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/icon-layer/icon-layer.js
Expand Up @@ -103,7 +103,7 @@ export default class IconLayer extends Layer {
update: this.calculateInstanceColorMode
},
instanceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getColor',
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/line-layer/line-layer.js
Expand Up @@ -68,7 +68,7 @@ export default class LineLayer extends Layer {
update: this.calculateInstanceSourceTargetPositions64xyLow
},
instanceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getColor',
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/path-layer/path-layer.js
Expand Up @@ -120,7 +120,7 @@ export default class PathLayer extends Layer {
},
instanceDashArrays: {size: 2, accessor: 'getDashArray'},
instanceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
accessor: 'getColor',
transition: ATTRIBUTE_TRANSITION,
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/point-cloud-layer/point-cloud-layer.js
Expand Up @@ -89,7 +89,7 @@ export default class PointCloudLayer extends Layer {
defaultValue: DEFAULT_NORMAL
},
instanceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: true,
accessor: 'getColor',
Expand Down
5 changes: 4 additions & 1 deletion modules/layers/src/polygon-layer/polygon-layer.js
Expand Up @@ -135,7 +135,8 @@ export default class PolygonLayer extends CompositeLayer {
extruded,
wireframe,
elevationScale,
transitions
transitions,
positionFormat
} = this.props;

// Rendering props underlying layer
Expand Down Expand Up @@ -196,6 +197,7 @@ export default class PolygonLayer extends CompositeLayer {
}),
{
data,
positionFormat,
getPolygon
}
);
Expand Down Expand Up @@ -236,6 +238,7 @@ export default class PolygonLayer extends CompositeLayer {
}),
{
data: paths,
positionFormat,
getPath: x => x.path
}
);
Expand Down
4 changes: 2 additions & 2 deletions modules/layers/src/scatterplot-layer/scatterplot-layer.js
Expand Up @@ -76,14 +76,14 @@ export default class ScatterplotLayer extends Layer {
defaultValue: 1
},
instanceFillColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
transition: true,
type: GL.UNSIGNED_BYTE,
accessor: 'getFillColor',
defaultValue: [0, 0, 0, 255]
},
instanceLineColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
transition: true,
type: GL.UNSIGNED_BYTE,
accessor: 'getLineColor',
Expand Down
4 changes: 2 additions & 2 deletions modules/layers/src/solid-polygon-layer/solid-polygon-layer.js
Expand Up @@ -149,7 +149,7 @@ export default class SolidPolygonLayer extends Layer {
},
fillColors: {
alias: 'colors',
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getFillColor',
Expand All @@ -165,7 +165,7 @@ export default class SolidPolygonLayer extends Layer {
},
lineColors: {
alias: 'colors',
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
type: GL.UNSIGNED_BYTE,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getLineColor',
Expand Down
Expand Up @@ -76,7 +76,7 @@ export default class ScenegraphLayer extends Layer {
update: this.calculateInstancePositions64xyLow
},
instanceColors: {
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
accessor: 'getColor',
defaultValue: DEFAULT_COLOR,
transition: true
Expand Down
Expand Up @@ -137,7 +137,7 @@ export default class SimpleMeshLayer extends Layer {
},
instanceColors: {
transition: true,
size: 4,
size: this.props.colorFormat === 'RGB' ? 3 : 4,
accessor: 'getColor',
defaultValue: [0, 0, 0, 255]
},
Expand Down

0 comments on commit ee6d200

Please sign in to comment.