Skip to content

Commit

Permalink
render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Mar 19, 2024
1 parent 4fdb04b commit 51b71fc
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 80 deletions.
23 changes: 15 additions & 8 deletions modules/core/src/lib/layer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export default class LayerManager {
private _needsUpdate: string | false = false;
private _nextLayers: LayersList | null = null;
private _debug: boolean = false;
// This flag is sepaprate from _needsUpdate because it can be set during an update and should trigger another full update
private _defaultShaderModulesChanged: boolean = false;

/**
* @param device
Expand Down Expand Up @@ -154,6 +156,9 @@ export default class LayerManager {
// New layers array may be the same as the old one if `setProps` is called by React
return 'layers changed';
}
if (this._defaultShaderModulesChanged) {
return 'shader modules changed';
}
return this._needsUpdate;
}

Expand Down Expand Up @@ -245,10 +250,7 @@ export default class LayerManager {
const {defaultShaderModules} = this.context;
if (!defaultShaderModules.find(m => m.name === module.name)) {
defaultShaderModules.push(module);
for (const layer of this.layers) {
layer.setNeedsUpdate();
layer.setChangeFlags({extensionsChanged: true});
}
this._defaultShaderModulesChanged = true;
}
}

Expand All @@ -258,10 +260,7 @@ export default class LayerManager {
const i = defaultShaderModules.findIndex(m => m.name === module.name);
if (i >= 0) {
defaultShaderModules.splice(i, 1);
for (const layer of this.layers) {
layer.setNeedsUpdate();
layer.setChangeFlags({extensionsChanged: true});
}
this._defaultShaderModulesChanged = true;
}
}

Expand All @@ -283,6 +282,14 @@ export default class LayerManager {
}
}

if (this._defaultShaderModulesChanged) {
for (const layer of oldLayers) {
layer.setNeedsUpdate();
layer.setChangeFlags({extensionsChanged: true});
}
this._defaultShaderModulesChanged = false;
}

// Allocate array for generated layers
const generatedLayers: Layer[] = [];

Expand Down
5 changes: 2 additions & 3 deletions modules/core/src/passes/shadow-pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default class ShadowPass extends LayersPass {
{
depthRange: [0, 1],
depthTest: true,
blend: false,
clearColor: [1, 1, 1, 1]
blend: false
},
() => {
// @ts-expect-error TODO - assuming WebGL context
Expand All @@ -69,7 +68,7 @@ export default class ShadowPass extends LayersPass {
target.resize({width, height});
}

super.render({...params, target, pass: 'shadow'});
super.render({...params, target, pass: 'shadow', clearColor: [1, 1, 1, 1]});
}
);
}
Expand Down
4 changes: 3 additions & 1 deletion modules/core/src/shaderlib/shadow/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ function createShadowUniforms(
if (!shadowEnabled || !opts.shadowMatrices || !opts.shadowMatrices.length) {
return {
shadow_uDrawShadowMap: false,
shadow_uUseShadowMap: false
shadow_uUseShadowMap: false,
shadow_uShadowMap0: opts.dummyShadowMap,
shadow_uShadowMap1: opts.dummyShadowMap
};
}
const uniforms = {
Expand Down
6 changes: 5 additions & 1 deletion modules/test-utils/src/snapshot-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ const DEFAULT_TEST_CASE: SnapshotTestCase = {
// eslint-disable-line
},
onAfterRender: ({deck, layers, done}) => {
if (layers.every(layer => layer.isLoaded)) {
if (
// @ts-expect-error accessing private
!deck.layerManager?.needsUpdate() &&
layers.every(layer => layer.isLoaded)
) {
done(); // eslint-disable-line
}
},
Expand Down
6 changes: 1 addition & 5 deletions test/render/test-cases/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {zoomBlur, vignette} from '@luma.gl/shadertools';
import {hexagons, points} from 'deck.gl-test/data';

import {ScatterplotLayer, SolidPolygonLayer, ColumnLayer} from '@deck.gl/layers';
// TODO v9
// import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
import {MaskExtension} from '@deck.gl/extensions';

import {CubeGeometry} from '@luma.gl/engine';
Expand All @@ -22,8 +21,6 @@ const MASK_POLYGON = [
];

export default [
// TODO v9
/*
{
name: 'shadow-effect',
effects: [
Expand Down Expand Up @@ -75,7 +72,6 @@ export default [
],
goldenImage: './test/render/golden-images/shadow-effect.png'
},
*/
...[true, false].map(maskInverted => ({
name: `mask-effect${maskInverted ? '-inverted' : ''}`,
viewState: {
Expand Down
2 changes: 1 addition & 1 deletion test/render/test-cases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ export default [].concat(
effectsTests,
transitionTests,
terrainLayerTests,
// collisionFilterExtensionTests
// collisionFilterExtensionTests,
dataFilterExtensionTests
);
121 changes: 60 additions & 61 deletions test/render/test-cases/terrain-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,66 +33,65 @@ export default [
})
],
goldenImage: './test/render/golden-images/terrain-layer.png'
},
{
name: 'terrain-extension-drape',
viewState: {
longitude: -122.45,
latitude: 37.75,
zoom: 11.5,
pitch: 60,
bearing: 0
},
layers: [
new TerrainLayer({
elevationData: ELEVATION_DATA,
texture: TEXTURE,
elevationDecoder: DECODER,
operation: 'draw+terrain'
}),
new GeoJsonLayer({
data: choropleths,
getLineWidth: 50,
getFillColor: (_, {index}) => [(index % 3) * 80, (index % 2) * 128, 128, 200],
extensions: [new TerrainExtension()]
})
],
goldenImage: './test/render/golden-images/terrain-extension-drape.png'
},
{
name: 'terrain-extension-offset',
viewState: {
longitude: -122.45,
latitude: 37.75,
zoom: 11.5,
pitch: 60,
bearing: 0
},
layers: [
new TerrainLayer({
elevationData: ELEVATION_DATA,
texture: TEXTURE,
elevationDecoder: DECODER,
operation: 'terrain'
}),
new GeoJsonLayer({
data: choropleths,
getLineWidth: 50,
getFillColor: (_, {index}) => [(index % 3) * 60 + 60, (index % 2) * 64 + 128, 200],
extensions: [new TerrainExtension()]
}),
new IconLayer({
data: points,
iconAtlas: './test/data/icon-atlas.png',
iconMapping,
sizeScale: 12,
getPosition: d => d.COORDINATES,
getIcon: d => 'marker-warning',
getSize: d => (d.PLACEMENT === 'SW' ? 0 : 2),
extensions: [new TerrainExtension()]
})
],
goldenImage: './test/render/golden-images/terrain-extension-offset.png'
}
// TODO - v9 TerrainExtension
// {
// name: 'terrain-extension-drape',
// viewState: {
// longitude: -122.45,
// latitude: 37.75,
// zoom: 11.5,
// pitch: 60,
// bearing: 0
// },
// layers: [
// new TerrainLayer({
// elevationData: ELEVATION_DATA,
// texture: TEXTURE,
// elevationDecoder: DECODER,
// operation: 'draw+terrain'
// }),
// new GeoJsonLayer({
// data: choropleths,
// getLineWidth: 50,
// getFillColor: (_, {index}) => [(index % 3) * 80, (index % 2) * 128, 128, 200],
// extensions: [new TerrainExtension()]
// })
// ],
// goldenImage: './test/render/golden-images/terrain-extension-drape.png'
// },
// {
// name: 'terrain-extension-offset',
// viewState: {
// longitude: -122.45,
// latitude: 37.75,
// zoom: 11.5,
// pitch: 60,
// bearing: 0
// },
// layers: [
// new TerrainLayer({
// elevationData: ELEVATION_DATA,
// texture: TEXTURE,
// elevationDecoder: DECODER,
// operation: 'terrain'
// }),
// new GeoJsonLayer({
// data: choropleths,
// getLineWidth: 50,
// getFillColor: (_, {index}) => [(index % 3) * 60 + 60, (index % 2) * 64 + 128, 200],
// extensions: [new TerrainExtension()]
// }),
// new IconLayer({
// data: points,
// iconAtlas: './test/data/icon-atlas.png',
// iconMapping,
// sizeScale: 12,
// getPosition: d => d.COORDINATES,
// getIcon: d => 'marker-warning',
// getSize: d => (d.PLACEMENT === 'SW' ? 0 : 2),
// extensions: [new TerrainExtension()]
// })
// ],
// goldenImage: './test/render/golden-images/terrain-extension-offset.png'
// }
];

0 comments on commit 51b71fc

Please sign in to comment.