Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/typescript/mini-cs…
Browse files Browse the repository at this point in the history
…s-extract-plugin-2.7.6
  • Loading branch information
hkfb authored Nov 2, 2023
2 parents ffffd21 + ae75b98 commit d897e24
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -98,7 +98,7 @@ jobs:
git clean -f -f -d -x
git rm -r --ignore-unmatch *
mv ../storybook-static .
mv ../../storybook-static .
git add .
Expand Down
14 changes: 14 additions & 0 deletions typescript/packages/subsurface-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.5.4](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@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/[email protected]@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/[email protected]@0.5.2) (2023-10-25)


Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/subsurface-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webviz/subsurface-viewer",
"version": "0.5.2",
"version": "0.5.4",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void main(void) {
color = texture2D(colormap, vec2(x, 0.5));
}
// 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);
// 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);
}
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ void main(void) {
color = color * vec4(c, c, c, 1.0);
}
// Use normal lighting. This has no effect if "material" property is not set.
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
// 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);
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export type Params = {
frame: Frame;
smoothShading: boolean;
gridLines: boolean;
ZIncreasingDownwards: boolean;
};

/**
Expand Down Expand Up @@ -337,7 +336,6 @@ export default class MapLayer extends CompositeLayer<MapLayerProps> {
frame: this.props.frame,
smoothShading: this.props.smoothShading,
gridLines: this.props.gridLines,
ZIncreasingDownwards: this.props.ZIncreasingDownwards,
};

const [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export default class privateMapLayer extends Layer<privateMapLayerProps> {
isColorMapClampColorTransparent,
isClampColor,
smoothShading,
ZIncreasingDownwards: this.props.ZIncreasingDownwards,
})
.draw();
gl.disable(GL.POLYGON_OFFSET_FILL);
Expand All @@ -236,7 +237,12 @@ export default class privateMapLayer extends Layer<privateMapLayerProps> {
}

if (this.props.gridLines) {
mesh_lines_model.draw();
mesh_lines_model
.setUniforms({
...uniforms,
ZIncreasingDownwards: this.props.ZIncreasingDownwards,
})
.draw();
}

if (!this.state["isLoaded"]) {
Expand Down
28 changes: 12 additions & 16 deletions typescript/packages/subsurface-viewer/src/layers/map/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ function calcNormal(
ox: number,
oy: number,
dx: number,
dy: number,
multZ: number
dy: number
) {
if (!smoothShading) {
return [1, 1, 1];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];

Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ 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;
vColor = vec4(colors.rgb, 1.0);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d897e24

Please sign in to comment.