Skip to content

Commit

Permalink
fix: [NGRM] - Strange artefacts in 2D maps #2134
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscb committed Jul 3, 2024
1 parent 8dcb471 commit 6156de9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Binary file added example-data/ArtefactsMap/points.bin
Binary file not shown.
Binary file added example-data/ArtefactsMap/properties.bin
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ void main(void) {
vec4 color = vec4(1.0, 1.0, 1.0, 1.0);;
float propertyValue = property;
// This may happen due to GPU interpolation precision causing color artifacts.
if (propertyValue < valueRangeMin ) {
propertyValue = valueRangeMin;
}
else if (propertyValue > valueRangeMax) {
propertyValue = valueRangeMax;
}
float x = (propertyValue - colorMapRangeMin) / (colorMapRangeMax - colorMapRangeMin);
if (x < 0.0 || x > 1.0) {
// Out of range. Use clampcolor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ const smallLayer = {
colorMapClampColor: [255, 0, 0],
};

const artefactsMapLayer = {
"@@type": "MapLayer",
id: "artefacts-map-layer",
meshData: "ArtefactsMap/points.bin",
frame: {
origin: [1134, 9317.966796875],
count: [81, 92],
increment: [101.04595712679287, -100.58940471369598],

rotDeg: 0.10652954894901544,
},
propertiesData: "ArtefactsMap/properties.bin",
gridLines: false,
material: false,
// black to white colors.
colorMapFunction: [0, 0, 0],
colorMapRange: [-0.01, 33], // actual range is [0, 34.764503479003906]
colorMapClampColor: [0, 255, 0],
};

// This layer has as many property values as depth values hence each cell will be interpolated in color.
const nodeCenteredPropertiesLayer = {
"@@type": "MapLayer",
Expand Down Expand Up @@ -322,6 +342,12 @@ const axes_small = {
bounds: [459790, 5929776, 0, 460590, 5930626, 30],
};

const axes_artefact_map = {
"@@type": "AxesLayer",
id: "axes_artefact_map",
bounds: [0, 0, 0, 10000, 10000, 30],
};

export const SmallMap: StoryObj<typeof SubsurfaceViewer> = {
args: {
id: "map",
Expand All @@ -339,6 +365,23 @@ export const SmallMap: StoryObj<typeof SubsurfaceViewer> = {
},
};

export const MapWithArtefacts: StoryObj<typeof SubsurfaceViewer> = {
args: {
id: "artefacts-map",
layers: [axes_artefact_map, artefactsMapLayer],
bounds: [0, 0, 10000, 10000] as BoundingBox2D,
views: default3DViews,
},
parameters: {
docs: {
...defaultStoryParameters.docs,
description: {
story: "Map with color artefacts.",
},
},
},
};

const axes_lite = {
"@@type": "AxesLayer",
id: "axes_small",
Expand Down

0 comments on commit 6156de9

Please sign in to comment.