From 674a51b7465a8f35d586a23edb5be8b4ed18d2e6 Mon Sep 17 00:00:00 2001 From: nilscb Date: Fri, 27 Oct 2023 11:27:57 +0200 Subject: [PATCH 1/6] Apply local phong lighting to MapLayer and Grid3D layer as already done in TriangleLayer. (#1738) - This algorithm is a modification of Luma's version in that it accounts for two sided lighting. - also rename privatLayer.ts to privatGrid3dLayer.ts to align with naming convention --- .../subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts | 4 ++-- .../subsurface-viewer/src/layers/grid3d/grid3dLayer.ts | 4 ++-- .../layers/grid3d/{privateLayer.ts => privateGrid3dLayer.ts} | 0 .../packages/subsurface-viewer/src/layers/grid3d/webworker.ts | 2 +- .../subsurface-viewer/src/layers/map/fragment.fs.glsl.ts | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) rename typescript/packages/subsurface-viewer/src/layers/grid3d/{privateLayer.ts => privateGrid3dLayer.ts} (100%) diff --git a/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts index 9482c1617..e4036f114 100644 --- a/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts @@ -56,8 +56,8 @@ void main(void) { } // Use normal lighting. This has no effect if "material" property is not set. - vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); - gl_FragColor = vec4(lightColor, 1.0); + vec3 lightColor = getPhongLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); + gl_FragColor = vec4(lightColor, 1.0); DECKGL_FILTER_COLOR(gl_FragColor, geometry); } `; diff --git a/typescript/packages/subsurface-viewer/src/layers/grid3d/grid3dLayer.ts b/typescript/packages/subsurface-viewer/src/layers/grid3d/grid3dLayer.ts index 831018bdb..a4775fe45 100644 --- a/typescript/packages/subsurface-viewer/src/layers/grid3d/grid3dLayer.ts +++ b/typescript/packages/subsurface-viewer/src/layers/grid3d/grid3dLayer.ts @@ -1,7 +1,7 @@ import type { Color } from "@deck.gl/core/typed"; import { CompositeLayer } from "@deck.gl/core/typed"; -import type { Material } from "./privateLayer"; -import privateLayer from "./privateLayer"; +import type { Material } from "./privateGrid3dLayer"; +import privateLayer from "./privateGrid3dLayer"; import type { ExtendedLayerProps, colorMapFunctionType, diff --git a/typescript/packages/subsurface-viewer/src/layers/grid3d/privateLayer.ts b/typescript/packages/subsurface-viewer/src/layers/grid3d/privateGrid3dLayer.ts similarity index 100% rename from typescript/packages/subsurface-viewer/src/layers/grid3d/privateLayer.ts rename to typescript/packages/subsurface-viewer/src/layers/grid3d/privateGrid3dLayer.ts diff --git a/typescript/packages/subsurface-viewer/src/layers/grid3d/webworker.ts b/typescript/packages/subsurface-viewer/src/layers/grid3d/webworker.ts index 7c2d87436..027b4c4e4 100644 --- a/typescript/packages/subsurface-viewer/src/layers/grid3d/webworker.ts +++ b/typescript/packages/subsurface-viewer/src/layers/grid3d/webworker.ts @@ -1,4 +1,4 @@ -import type { MeshType, MeshTypeLines } from "./privateLayer"; +import type { MeshType, MeshTypeLines } from "./privateGrid3dLayer"; import type { WebWorkerParams } from "./grid3dLayer"; export function makeFullMesh(e: { data: WebWorkerParams }): void { diff --git a/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts index ad9056be3..2ddaa6d13 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts @@ -94,9 +94,8 @@ void main(void) { } // Use normal lighting. This has no effect if "material" property is not set. - vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); + vec3 lightColor = getPhongLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); gl_FragColor = vec4(lightColor, 1.0); - DECKGL_FILTER_COLOR(gl_FragColor, geometry); } `; From 64938ee977db4ec01c1ea09135827bc2af837018 Mon Sep 17 00:00:00 2001 From: t0oF-azpn <93762994+t0oF-azpn@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:18:42 +0200 Subject: [PATCH 2/6] fix: force publishing a new package (#1740) Previous PR had a title that does not trigger a semantic release. --- .../subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts | 2 +- .../subsurface-viewer/src/layers/map/fragment.fs.glsl.ts | 2 +- .../subsurface-viewer/src/layers/triangle/fragment.fs.glsl.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts index e4036f114..c85f81014 100644 --- a/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/grid3d/fragment.fs.glsl.ts @@ -55,7 +55,7 @@ void main(void) { color = texture2D(colormap, vec2(x, 0.5)); } - // Use normal lighting. This has no effect if "material" property is not set. + // Use two sided phong lighting. This has no effect if "material" property is not set. vec3 lightColor = getPhongLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); gl_FragColor = vec4(lightColor, 1.0); DECKGL_FILTER_COLOR(gl_FragColor, geometry); diff --git a/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts index 2ddaa6d13..e7991498c 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/fragment.fs.glsl.ts @@ -93,7 +93,7 @@ void main(void) { color = color * vec4(c, c, c, 1.0); } - // Use normal lighting. This has no effect if "material" property is not set. + // Use two sided phong lighting. This has no effect if "material" property is not set. vec3 lightColor = getPhongLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); gl_FragColor = vec4(lightColor, 1.0); DECKGL_FILTER_COLOR(gl_FragColor, geometry); diff --git a/typescript/packages/subsurface-viewer/src/layers/triangle/fragment.fs.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/triangle/fragment.fs.glsl.ts index 01c7fee9e..474bdec0b 100644 --- a/typescript/packages/subsurface-viewer/src/layers/triangle/fragment.fs.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/triangle/fragment.fs.glsl.ts @@ -40,7 +40,7 @@ void main(void) { color = color * vec4(c, c, c, 1.0); } - // Use normal lighting. This has no effect if "material" property is not set. + // Use two sided phong lighting. This has no effect if "material" property is not set. vec3 lightColor = getPhongLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); gl_FragColor = vec4(lightColor, 1.0); DECKGL_FILTER_COLOR(gl_FragColor, geometry); From 270d5d4478c9a73350f9fa7a300aef497b1cb277 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 27 Oct 2023 10:20:45 +0000 Subject: [PATCH 3/6] chore(release): 0.5.3 [skip ci] ## [0.5.3](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.2...subsurface-viewer@0.5.3) (2023-10-27) ### Bug Fixes * force publishing a new package ([#1740](https://github.com/equinor/webviz-subsurface-components/issues/1740)) ([64938ee](https://github.com/equinor/webviz-subsurface-components/commit/64938ee977db4ec01c1ea09135827bc2af837018)) --- typescript/packages/subsurface-viewer/CHANGELOG.md | 7 +++++++ typescript/packages/subsurface-viewer/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/typescript/packages/subsurface-viewer/CHANGELOG.md b/typescript/packages/subsurface-viewer/CHANGELOG.md index dfe50ea35..68d403b4f 100644 --- a/typescript/packages/subsurface-viewer/CHANGELOG.md +++ b/typescript/packages/subsurface-viewer/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.5.3](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.2...subsurface-viewer@0.5.3) (2023-10-27) + + +### Bug Fixes + +* force publishing a new package ([#1740](https://github.com/equinor/webviz-subsurface-components/issues/1740)) ([64938ee](https://github.com/equinor/webviz-subsurface-components/commit/64938ee977db4ec01c1ea09135827bc2af837018)) + ## [0.5.2](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.1...subsurface-viewer@0.5.2) (2023-10-25) diff --git a/typescript/packages/subsurface-viewer/package.json b/typescript/packages/subsurface-viewer/package.json index ba8887dc7..a370cf8b6 100644 --- a/typescript/packages/subsurface-viewer/package.json +++ b/typescript/packages/subsurface-viewer/package.json @@ -1,6 +1,6 @@ { "name": "@webviz/subsurface-viewer", - "version": "0.5.2", + "version": "0.5.3", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From ed85f7f6bd5e1841518e0c52448e90eba3c8b988 Mon Sep 17 00:00:00 2001 From: nilscb Date: Fri, 27 Oct 2023 15:15:19 +0200 Subject: [PATCH 4/6] perf: Apply flag "ZIncreasingDownwards" in vertex shaders MapLayer. (#1741) - This is related to earlier commit. MapLayer was missing - Earlier commit: performance: Apply flag "ZIncreasingDownwards" in vertex shaders for relevant layers. #1724 (#1737) --- .../src/layers/map/mapLayer.ts | 2 -- .../src/layers/map/privateMapLayer.ts | 8 +++++- .../subsurface-viewer/src/layers/map/utils.ts | 28 ++++++++----------- .../src/layers/map/vertex.glsl.ts | 8 ++++-- .../src/layers/map/vertex_lines.glsl.ts | 7 ++++- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/typescript/packages/subsurface-viewer/src/layers/map/mapLayer.ts b/typescript/packages/subsurface-viewer/src/layers/map/mapLayer.ts index 12e80d168..09b7d41c1 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/mapLayer.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/mapLayer.ts @@ -55,7 +55,6 @@ export type Params = { frame: Frame; smoothShading: boolean; gridLines: boolean; - ZIncreasingDownwards: boolean; }; /** @@ -337,7 +336,6 @@ export default class MapLayer extends CompositeLayer { frame: this.props.frame, smoothShading: this.props.smoothShading, gridLines: this.props.gridLines, - ZIncreasingDownwards: this.props.ZIncreasingDownwards, }; const [ diff --git a/typescript/packages/subsurface-viewer/src/layers/map/privateMapLayer.ts b/typescript/packages/subsurface-viewer/src/layers/map/privateMapLayer.ts index 4e967abd0..ed994b7fa 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/privateMapLayer.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/privateMapLayer.ts @@ -227,6 +227,7 @@ export default class privateMapLayer extends Layer { isColorMapClampColorTransparent, isClampColor, smoothShading, + ZIncreasingDownwards: this.props.ZIncreasingDownwards, }) .draw(); gl.disable(GL.POLYGON_OFFSET_FILL); @@ -236,7 +237,12 @@ export default class privateMapLayer extends Layer { } if (this.props.gridLines) { - mesh_lines_model.draw(); + mesh_lines_model + .setUniforms({ + ...uniforms, + ZIncreasingDownwards: this.props.ZIncreasingDownwards, + }) + .draw(); } if (!this.state["isLoaded"]) { diff --git a/typescript/packages/subsurface-viewer/src/layers/map/utils.ts b/typescript/packages/subsurface-viewer/src/layers/map/utils.ts index 3bdeae46a..b0f8a5422 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/utils.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/utils.ts @@ -44,8 +44,7 @@ function calcNormal( ox: number, oy: number, dx: number, - dy: number, - multZ: number + dy: number ) { if (!smoothShading) { return [1, 1, 1]; @@ -73,11 +72,11 @@ function calcNormal( } const hh = ny - 1 - h; // Note use hh for h for getting y values. - const p0 = [ox + w * dx, oy + hh * dy, i0_act ? -meshData[i0] * multZ : 0]; // eslint-disable-line - const p1 = [ ox + (w - 1) * dx, oy + hh * dy, i1_act ? -meshData[i1] * multZ : 0]; // eslint-disable-line - const p2 = [ ox + w * dx, oy + (hh + 1) * dy, i2_act ? -meshData[i2] * multZ : 0]; // eslint-disable-line - const p3 = [ ox + (w + 1) * dx, oy + hh * dy, i3_act ? -meshData[i3] * multZ : 0]; // eslint-disable-line - const p4 = [ ox + w * dx, oy + (hh - 1) * dy, i4_act ? -meshData[i4] * multZ : 0]; // eslint-disable-line + const p0 = [ox + w * dx, oy + hh * dy, i0_act ? meshData[i0] : 0]; // eslint-disable-line + const p1 = [ ox + (w - 1) * dx, oy + hh * dy, i1_act ? meshData[i1] : 0]; // eslint-disable-line + const p2 = [ ox + w * dx, oy + (hh + 1) * dy, i2_act ? meshData[i2] : 0]; // eslint-disable-line + const p3 = [ ox + (w + 1) * dx, oy + hh * dy, i3_act ? meshData[i3] : 0]; // eslint-disable-line + const p4 = [ ox + w * dx, oy + (hh - 1) * dy, i4_act ? meshData[i4] : 0]; // eslint-disable-line const v1 = [p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2]] as Vec; const v2 = [p2[0] - p0[0], p2[1] - p0[1], p2[2] - p0[2]] as Vec; @@ -143,9 +142,6 @@ export function makeFullMesh(params: Params) { const frame = params.frame; const smoothShading = params.smoothShading; const gridLines = params.gridLines; - const ZIncreasingDownwards = params.ZIncreasingDownwards; - - const multZ = ZIncreasingDownwards ? 1 : -1; const meshZValueRange = getFloat32ArrayMinMax(meshData); const propertyValueRange = getFloat32ArrayMinMax(propertiesData); @@ -206,7 +202,7 @@ export function makeFullMesh(params: Params) { const x0 = ox + w * dx; const y0 = oy + (ny - 1 - h) * dy; // See note above. - const z = isMesh ? -meshData[i0] * multZ : 0; + const z = isMesh ? meshData[i0] : 0; const propertyValue = propertiesData[i0]; @@ -215,7 +211,7 @@ export function makeFullMesh(params: Params) { positions[3 * i + 2] = z; if (smoothShading) { - const normal = calcNormal(w, h, nx, ny, isMesh, smoothShading, meshData, ox, oy, dx, dy, multZ); // eslint-disable-line + const normal = calcNormal(w, h, nx, ny, isMesh, smoothShading, meshData, ox, oy, dx, dy); // eslint-disable-line normals[3 * i + 0] = normal[0] * 127; // Normalize to signed 8 bit. normals[3 * i + 1] = normal[1] * 127; normals[3 * i + 2] = normal[2] * 127; @@ -334,19 +330,19 @@ export function makeFullMesh(params: Params) { const x0 = ox + w * dx; const y0 = oy + hh * dy; - const z0 = isMesh ? -meshData[i0] * multZ : 0; + const z0 = isMesh ? meshData[i0] : 0; const x1 = ox + (w + 1) * dx; const y1 = oy + hh * dy; - const z1 = isMesh ? -meshData[i1] * multZ : 0; + const z1 = isMesh ? meshData[i1] : 0; const x2 = ox + (w + 1) * dx; const y2 = oy + (hh - 1) * dy; // Note hh - 1 here. - const z2 = isMesh ? -meshData[i2] * multZ : 0; + const z2 = isMesh ? meshData[i2] : 0; const x3 = ox + w * dx; const y3 = oy + (hh - 1) * dy; // Note hh - 1 here. - const z3 = isMesh ? -meshData[i3] * multZ : 0; + const z3 = isMesh ? meshData[i3] : 0; const propertyIndex = h * (nx - 1) + w; // (nx - 1) -> the width of the property 2D array is one less than for the nodes in this case. const propertyValue = propertiesData[propertyIndex]; diff --git a/typescript/packages/subsurface-viewer/src/layers/map/vertex.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/map/vertex.glsl.ts index cecf04760..11fa35277 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/vertex.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/vertex.glsl.ts @@ -20,14 +20,18 @@ out vec3 worldPos; out float property; flat out int vertexIndex; +uniform bool ZIncreasingDownwards; void main(void) { geometry.pickingColor = vec3(1.0, 1.0, 0.0); vertexIndex = gl_VertexID; + vec3 position = positions; + position[2] *= ZIncreasingDownwards ? -1.0 : 1.0; + cameraPosition = project_uCameraPosition; - worldPos = positions; + worldPos = position; normals_commonspace = normals; @@ -35,7 +39,7 @@ void main(void) { property = properties; - position_commonspace = vec4(project_position(positions), 0.0); + position_commonspace = vec4(project_position(position), 0.0); gl_Position = project_common_position_to_clipspace(position_commonspace); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); diff --git a/typescript/packages/subsurface-viewer/src/layers/map/vertex_lines.glsl.ts b/typescript/packages/subsurface-viewer/src/layers/map/vertex_lines.glsl.ts index 286877acb..eedc8fdee 100644 --- a/typescript/packages/subsurface-viewer/src/layers/map/vertex_lines.glsl.ts +++ b/typescript/packages/subsurface-viewer/src/layers/map/vertex_lines.glsl.ts @@ -8,8 +8,13 @@ in vec3 positions; out vec4 position_commonspace; +uniform bool ZIncreasingDownwards; + void main(void) { - vec3 position_commonspace = project_position(positions); + vec3 position = positions; + position[2] *= ZIncreasingDownwards ? -1.0 : 1.0; + + vec3 position_commonspace = project_position(position); gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 0.0)); } `; From 821b6bd4ec8296e140f01c2f70c9f686bddbbb27 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 27 Oct 2023 13:18:08 +0000 Subject: [PATCH 5/6] chore(release): 0.5.4 [skip ci] ## [0.5.4](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.3...subsurface-viewer@0.5.4) (2023-10-27) ### Performance Improvements * Apply flag "ZIncreasingDownwards" in vertex shaders MapLayer. ([#1741](https://github.com/equinor/webviz-subsurface-components/issues/1741)) ([ed85f7f](https://github.com/equinor/webviz-subsurface-components/commit/ed85f7f6bd5e1841518e0c52448e90eba3c8b988)), closes [#1724](https://github.com/equinor/webviz-subsurface-components/issues/1724) [#1737](https://github.com/equinor/webviz-subsurface-components/issues/1737) --- typescript/packages/subsurface-viewer/CHANGELOG.md | 7 +++++++ typescript/packages/subsurface-viewer/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/typescript/packages/subsurface-viewer/CHANGELOG.md b/typescript/packages/subsurface-viewer/CHANGELOG.md index 68d403b4f..b4ea0ee0a 100644 --- a/typescript/packages/subsurface-viewer/CHANGELOG.md +++ b/typescript/packages/subsurface-viewer/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.5.4](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.3...subsurface-viewer@0.5.4) (2023-10-27) + + +### Performance Improvements + +* Apply flag "ZIncreasingDownwards" in vertex shaders MapLayer. ([#1741](https://github.com/equinor/webviz-subsurface-components/issues/1741)) ([ed85f7f](https://github.com/equinor/webviz-subsurface-components/commit/ed85f7f6bd5e1841518e0c52448e90eba3c8b988)), closes [#1724](https://github.com/equinor/webviz-subsurface-components/issues/1724) [#1737](https://github.com/equinor/webviz-subsurface-components/issues/1737) + ## [0.5.3](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.5.2...subsurface-viewer@0.5.3) (2023-10-27) diff --git a/typescript/packages/subsurface-viewer/package.json b/typescript/packages/subsurface-viewer/package.json index a370cf8b6..f2da4847b 100644 --- a/typescript/packages/subsurface-viewer/package.json +++ b/typescript/packages/subsurface-viewer/package.json @@ -1,6 +1,6 @@ { "name": "@webviz/subsurface-viewer", - "version": "0.5.3", + "version": "0.5.4", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From ae75b98b23e528c7a8f31543e6d037916d6fcca7 Mon Sep 17 00:00:00 2001 From: t0oF-azpn <93762994+t0oF-azpn@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:36:48 +0100 Subject: [PATCH 6/6] ci: an other tentative to fix the storybook pipeline (#1739) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit temp move storybook-static on more level up, to exit the git repo Co-authored-by: Håvard Bjerke --- .github/workflows/typescript.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index be4ecfa43..1c9659f3f 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -88,8 +88,8 @@ jobs: - name: 📚 Update Storybook if: github.event_name == 'push' && github.ref == 'refs/heads/master' run: | - rm -rf ../storybook-static - mv ./storybook-static .. + rm -rf ../../storybook-static + mv ./storybook-static ../.. git config --local user.email "webviz-github-action" git config --local user.name "webviz-github-action" @@ -98,7 +98,7 @@ jobs: git clean -f -f -d -x git rm -r --ignore-unmatch * - mv ../storybook-static . + mv ../../storybook-static . git add .