Skip to content

Commit 9676347

Browse files
authored
fix(core): correct opacity in interleaved mode (#9642)
1 parent b04748b commit 9676347

File tree

6 files changed

+52
-48
lines changed

6 files changed

+52
-48
lines changed

examples/layer-browser/src/app.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default class App extends PureComponent {
8888
useDevicePixels: true,
8989
pickingRadius: 0,
9090
drawPickingColors: false,
91+
interleaved: true,
9192

9293
// Model matrix manipulation
9394
separation: 0,

examples/layer-browser/src/map.jsx

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/* global window */
66

77
import React, {PureComponent} from 'react';
8-
import {Map} from 'react-map-gl/maplibre';
8+
import {Map, useControl} from 'react-map-gl/maplibre';
9+
import {MapboxOverlay} from '@deck.gl/mapbox';
910
import autobind from 'react-autobind';
1011

1112
import {DeckGL} from '@deck.gl/react';
@@ -42,10 +43,16 @@ const INITIAL_VIEW_STATES = {
4243
}
4344
};
4445

45-
const MAP_STYLE = 'https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json';
46+
const MAP_STYLE = 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json';
4647

4748
const ViewportLabel = props => <div style={VIEW_LABEL_STYLES}>{props.children}</div>;
4849

50+
function DeckGLOverlay(props) {
51+
const overlay = useControl(() => new MapboxOverlay(props));
52+
overlay.setProps(props);
53+
return null;
54+
}
55+
4956
export default class DeckMap extends PureComponent {
5057
constructor(props) {
5158
super(props);
@@ -55,7 +62,6 @@ export default class DeckMap extends PureComponent {
5562
hoveredItem: null,
5663
clickedItem: null,
5764
queriedItems: null,
58-
5965
enableDepthPickOnClick: false,
6066
metrics: null
6167
};
@@ -132,45 +138,36 @@ export default class DeckMap extends PureComponent {
132138
layers,
133139
views,
134140
effects,
135-
settings: {pickingRadius, drawPickingColors, useDevicePixels}
141+
settings: {pickingRadius, drawPickingColors, useDevicePixels, interleaved}
136142
} = this.props;
137143

138144
return (
139-
<div style={{backgroundColor: '#eeeeee'}}>
145+
<div style={{backgroundColor: '#eeeeee', height: '100vh', width: '100vw'}}>
140146
<div style={{position: 'absolute', top: '10px', left: '100px', zIndex: 999}}>
141147
<RenderMetrics metrics={this.state.metrics} />
142148
</div>
143-
<DeckGL
144-
ref={this.deckRef}
145-
id="default-deckgl-overlay"
146-
layers={layers}
147-
layerFilter={this._layerFilter}
148-
views={views}
149-
initialViewState={INITIAL_VIEW_STATES}
150-
effects={effects}
151-
pickingRadius={pickingRadius}
152-
onHover={this._onHover}
153-
onClick={this._onClick}
154-
useDevicePixels={useDevicePixels}
155-
debug={true}
156-
drawPickingColors={drawPickingColors}
157-
_onMetrics={this._onMetrics}
149+
<Map
150+
key={`map-${interleaved}`}
151+
mapStyle={MAP_STYLE}
152+
initialViewState={INITIAL_VIEW_STATES.basemap}
158153
>
159-
<View id="basemap">
160-
<Map key="map" mapStyle={MAP_STYLE} />
161-
<ViewportLabel key="label">Map View</ViewportLabel>
162-
</View>
163-
164-
<View id="first-person">
165-
<ViewportLabel>First Person View</ViewportLabel>
166-
</View>
167-
168-
<View id="infovis">
169-
<ViewportLabel>Orbit View (PlotLayer only, No Navigation)</ViewportLabel>
170-
</View>
171-
154+
<DeckGLOverlay
155+
layers={layers.map(l => l.clone({beforeId: 'watername_ocean'}))}
156+
initialViewState={INITIAL_VIEW_STATES}
157+
layerFilter={this._layerFilter}
158+
{...(!interleaved && {views})}
159+
effects={effects}
160+
pickingRadius={pickingRadius}
161+
onHover={this._onHover}
162+
onClick={this._onClick}
163+
useDevicePixels={useDevicePixels}
164+
debug={true}
165+
drawPickingColors={drawPickingColors}
166+
_onMetrics={this._onMetrics}
167+
interleaved={interleaved}
168+
/>
172169
<LayerInfo hovered={hoveredItem} clicked={clickedItem} queried={queriedItems} />
173-
</DeckGL>
170+
</Map>
174171
</div>
175172
);
176173
}

modules/carto/src/layers/raster-layer.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,7 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
145145
offset,
146146
lineWidthScale, // Re-use widthScale prop to pass cell scale,
147147
highlightedObjectIndex,
148-
highlightColor,
149-
150-
// RTT requires blending otherwise opacity < 1 blends with black
151-
// render target
152-
parameters: {
153-
blendColorSrcFactor: 'one',
154-
blendAlphaSrcFactor: 'one',
155-
blendColorDstFactor: 'zero',
156-
blendAlphaDstFactor: 'zero',
157-
blendColorOperation: 'add',
158-
blendAlphaOperation: 'add'
159-
}
148+
highlightColor
160149
}
161150
);
162151
}

modules/core/src/lib/deck-renderer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ export default class DeckRenderer {
8383
}
8484

8585
const outputBuffer = this.lastPostProcessEffect ? this.renderBuffers[0] : renderOpts.target;
86+
8687
if (this.lastPostProcessEffect) {
8788
renderOpts.clearColor = [0, 0, 0, 0];
8889
renderOpts.clearCanvas = true;
8990
}
9091
const renderStats = layerPass.render({...renderOpts, target: outputBuffer});
9192

9293
if (renderOpts.effects) {
94+
if (this.lastPostProcessEffect) {
95+
// Interleaved basemap rendering requires clearCanvas to be false
96+
renderOpts.clearCanvas = opts.clearCanvas === undefined ? true : opts.clearCanvas;
97+
}
98+
9399
this._postRender(renderOpts.effects, renderOpts);
94100
}
95101

modules/core/src/passes/screen-pass.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Attribution: This class and the multipass system were inspired by
66
// the THREE.js EffectComposer and *Pass classes
77

8-
import type {Device, Framebuffer} from '@luma.gl/core';
8+
import type {Device, Framebuffer, RenderPipelineParameters} from '@luma.gl/core';
99
import {ClipSpace} from '@luma.gl/engine';
1010
import type {ShaderModule} from '@luma.gl/shadertools';
1111
import Pass from './pass';
@@ -31,7 +31,18 @@ export default class ScreenPass extends Pass {
3131
constructor(device: Device, props: ScreenPassProps) {
3232
super(device, props);
3333
const {module, fs, id} = props;
34-
const parameters = {depthWriteEnabled: false, depthCompare: 'always' as const};
34+
const parameters: RenderPipelineParameters = {
35+
depthWriteEnabled: false,
36+
depthCompare: 'always' as const,
37+
depthBias: 0,
38+
blend: true,
39+
blendColorSrcFactor: 'one',
40+
blendColorDstFactor: 'one-minus-src-alpha',
41+
blendAlphaSrcFactor: 'one',
42+
blendAlphaDstFactor: 'one-minus-src-alpha',
43+
blendColorOperation: 'add',
44+
blendAlphaOperation: 'add'
45+
};
3546
this.model = new ClipSpace(device, {id, fs, modules: [module, screenUniforms], parameters});
3647
}
3748

-17.8 KB
Loading

0 commit comments

Comments
 (0)