From 67965fa18690983d4874a59d8254594aaa135b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=BC=C3=9Femeyer?= Date: Wed, 27 Nov 2024 17:24:24 +0100 Subject: [PATCH] rename resolution to magnification in shader relevant code --- .../materials/plane_material_factory.ts | 8 ++++---- .../javascripts/oxalis/shaders/coords.glsl.ts | 20 +++++++++---------- .../oxalis/shaders/main_data_shaders.glsl.ts | 12 +++++------ .../oxalis/shaders/texture_access.glsl.ts | 8 ++++---- .../test/fixtures/{resolutions.ts => mags.ts} | 0 .../test/shaders/shader_syntax.spec.ts | 14 ++++++------- 6 files changed, 31 insertions(+), 31 deletions(-) rename frontend/javascripts/test/fixtures/{resolutions.ts => mags.ts} (100%) diff --git a/frontend/javascripts/oxalis/geometries/materials/plane_material_factory.ts b/frontend/javascripts/oxalis/geometries/materials/plane_material_factory.ts index 90b887fb4d9..9fbcbaa9705 100644 --- a/frontend/javascripts/oxalis/geometries/materials/plane_material_factory.ts +++ b/frontend/javascripts/oxalis/geometries/materials/plane_material_factory.ts @@ -570,7 +570,7 @@ class PlaneMaterialFactory { resInfo.getDenseMags(), ); const flatMags = _.flattenDeep(allDenseMags); - this.uniforms.allResolutions = { + this.uniforms.allMagnifications = { value: flatMags, }; @@ -581,7 +581,7 @@ class PlaneMaterialFactory { magCountCumSum.push(cumSum); } - this.uniforms.resolutionCountCumSum = { + this.uniforms.magnificationCountCumSum = { value: magCountCumSum, }; }, @@ -1099,7 +1099,7 @@ class PlaneMaterialFactory { colorLayerNames, segmentationLayerNames, textureLayerInfos, - resolutionsCount: this.getTotalMagCount(), + magnificationsCount: this.getTotalMagCount(), voxelSizeFactor, isOrthogonal: this.isOrthogonal, tpsTransformPerLayer: this.scaledTpsInvPerLayer, @@ -1134,7 +1134,7 @@ class PlaneMaterialFactory { colorLayerNames, segmentationLayerNames, textureLayerInfos, - resolutionsCount: this.getTotalMagCount(), + magnificationsCount: this.getTotalMagCount(), voxelSizeFactor, isOrthogonal: this.isOrthogonal, tpsTransformPerLayer: this.scaledTpsInvPerLayer, diff --git a/frontend/javascripts/oxalis/shaders/coords.glsl.ts b/frontend/javascripts/oxalis/shaders/coords.glsl.ts index 5ae2157d59e..dff7a25cdfe 100644 --- a/frontend/javascripts/oxalis/shaders/coords.glsl.ts +++ b/frontend/javascripts/oxalis/shaders/coords.glsl.ts @@ -1,26 +1,26 @@ import { isFlightMode, getW } from "oxalis/shaders/utils.glsl"; import type { ShaderModule } from "./shader_module_system"; -export const getResolution: ShaderModule = { +export const getMagnification: ShaderModule = { code: ` - vec3 getResolution(uint zoomStep, uint globalLayerIndex) { - return allResolutions[zoomStep + resolutionCountCumSum[globalLayerIndex]]; + vec3 getMagnification(uint zoomStep, uint globalLayerIndex) { + return allMagnifications[zoomStep + magnificationCountCumSum[globalLayerIndex]]; } `, }; -export const getResolutionFactors: ShaderModule = { - requirements: [getResolution], +export const getMagnificationFactors: ShaderModule = { + requirements: [getMagnification], code: ` - vec3 getResolutionFactors(uint zoomStepA, uint zoomStepB, uint globalLayerIndex) { - return getResolution(zoomStepA, globalLayerIndex) / getResolution(zoomStepB, globalLayerIndex); + vec3 getMagnificationFactors(uint zoomStepA, uint zoomStepB, uint globalLayerIndex) { + return getMagnification(zoomStepA, globalLayerIndex) / getMagnification(zoomStepB, globalLayerIndex); } `, }; export const getAbsoluteCoords: ShaderModule = { - requirements: [getResolution], + requirements: [getMagnification], code: ` vec3 getAbsoluteCoords(vec3 worldCoordUVW, uint usedZoomStep, uint globalLayerIndex) { - vec3 resolution = getResolution(usedZoomStep, globalLayerIndex); - vec3 coords = transDim(worldCoordUVW) / resolution; + vec3 magnification = getMagnification(usedZoomStep, globalLayerIndex); + vec3 coords = transDim(worldCoordUVW) / magnification; return coords; } `, diff --git a/frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts b/frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts index e64d09f8839..4501f3bce64 100644 --- a/frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts +++ b/frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts @@ -11,7 +11,7 @@ import { import { getMaybeFilteredColorOrFallback } from "./filtering.glsl"; import { getAbsoluteCoords, - getResolution, + getMagnification, getWorldCoordUVW, isOutsideOfBoundingBox, } from "./coords.glsl"; @@ -41,7 +41,7 @@ type Params = { orderedColorLayerNames: string[]; segmentationLayerNames: string[]; textureLayerInfos: Record; - resolutionsCount: number; + magnificationsCount: number; voxelSizeFactor: Vector3; isOrthogonal: boolean; tpsTransformPerLayer: Record; @@ -52,8 +52,8 @@ uniform vec2 viewportExtent; uniform float activeMagIndices[<%= globalLayerCount %>]; uniform uint availableLayerIndexToGlobalLayerIndex[<%= globalLayerCount %>]; -uniform vec3 allResolutions[<%= resolutionsCount %>]; -uniform uint resolutionCountCumSum[<%= globalLayerCount %>]; +uniform vec3 allMagnifications[<%= magnificationsCount %>]; +uniform uint magnificationCountCumSum[<%= globalLayerCount %>]; uniform highp usampler2D lookup_texture; uniform highp uint lookup_seeds[3]; @@ -385,7 +385,7 @@ ${compileShader( isOutsideOfBoundingBox, getMaybeFilteredColorOrFallback, hasSegmentation ? getSegmentId : null, - getResolution, + getMagnification, almostEq, )} @@ -442,7 +442,7 @@ void main() { // Invert vertical axis to make calculation more intuitive with top-left coordinates. index.y = PLANE_SUBDIVISION - index.y; - // d is the width/height of a bucket in the current resolution. + // d is the width/height of a bucket in the current magnification. vec2 d = transDim(vec3(bucketWidth) * representativeMagForVertexAlignment).xy; vec3 voxelSizeFactorUVW = transDim(voxelSizeFactor); diff --git a/frontend/javascripts/oxalis/shaders/texture_access.glsl.ts b/frontend/javascripts/oxalis/shaders/texture_access.glsl.ts index e3a3bb82a4c..8e15185537e 100644 --- a/frontend/javascripts/oxalis/shaders/texture_access.glsl.ts +++ b/frontend/javascripts/oxalis/shaders/texture_access.glsl.ts @@ -1,5 +1,5 @@ import { MAX_ZOOM_STEP_DIFF } from "oxalis/model/bucket_data_handling/loading_strategy_logic"; -import { getResolutionFactors, getAbsoluteCoords } from "oxalis/shaders/coords.glsl"; +import { getMagnificationFactors, getAbsoluteCoords } from "oxalis/shaders/coords.glsl"; import { hashCombine } from "./hashing.glsl"; import type { ShaderModule } from "./shader_module_system"; import { transDim } from "./utils.glsl"; @@ -92,7 +92,7 @@ export const getColorForCoords: ShaderModule = { getRgbaAtIndex, getRgbaAtXYIndex, getAbsoluteCoords, - getResolutionFactors, + getMagnificationFactors, hashCombine, transDim, ], @@ -272,10 +272,10 @@ export const getColorForCoords: ShaderModule = { * If we are in the [5, _, _, 0]-bucket, we have to look into the **second** half * of the [2, _, _, 1]-bucket. * We can determine which "half" (subVolumeIndex) is relevant by doing a modulo operation - * with the resolution factor. A typical resolution factor is 2. + * with the magnification factor. A typical magnification factor is 2. */ - vec3 magnificationFactors = getResolutionFactors(renderedMagIdx, activeMagIdx, globalLayerIndex); + vec3 magnificationFactors = getMagnificationFactors(renderedMagIdx, activeMagIdx, globalLayerIndex); vec3 coords = floor(getAbsoluteCoords(worldPositionUVW, activeMagIdx, globalLayerIndex)); offsetInBucket = mod(coords, bucketWidth); vec3 worldBucketPosition = div(coords, bucketWidth); diff --git a/frontend/javascripts/test/fixtures/resolutions.ts b/frontend/javascripts/test/fixtures/mags.ts similarity index 100% rename from frontend/javascripts/test/fixtures/resolutions.ts rename to frontend/javascripts/test/fixtures/mags.ts diff --git a/frontend/javascripts/test/shaders/shader_syntax.spec.ts b/frontend/javascripts/test/shaders/shader_syntax.spec.ts index 8e47b614106..fc42fa4228f 100644 --- a/frontend/javascripts/test/shaders/shader_syntax.spec.ts +++ b/frontend/javascripts/test/shaders/shader_syntax.spec.ts @@ -1,6 +1,6 @@ import "test/mocks/lz4"; import getMainFragmentShader from "oxalis/shaders/main_data_shaders.glsl"; -import resolutions from "test/fixtures/resolutions"; +import mags from "test/fixtures/mags"; import test, { type ExecutionContext } from "ava"; import { parser } from "@shaderfrog/glsl-parser"; @@ -27,7 +27,7 @@ test("Shader syntax: Ortho Mode", (t: ExecutionContext) => { }, orderedColorLayerNames: ["color_layer_1", "color_layer_2"], segmentationLayerNames: [], - resolutionsCount: resolutions.length, + magnificationsCount: mags.length, voxelSizeFactor: [1, 1, 1], isOrthogonal: true, tpsTransformPerLayer: {}, @@ -54,7 +54,7 @@ test("Shader syntax: Ortho Mode + Segmentation - Mapping", (t: ExecutionContext< }, orderedColorLayerNames: ["color_layer_1", "color_layer_2"], segmentationLayerNames: ["segmentationLayer"], - resolutionsCount: resolutions.length, + magnificationsCount: mags.length, voxelSizeFactor: [1, 1, 1], isOrthogonal: true, tpsTransformPerLayer: {}, @@ -74,7 +74,7 @@ test("Shader syntax: Ortho Mode + Segmentation + Mapping", (t: ExecutionContext< }, orderedColorLayerNames: ["color_layer_1", "color_layer_2"], segmentationLayerNames: ["segmentationLayer"], - resolutionsCount: resolutions.length, + magnificationsCount: mags.length, voxelSizeFactor: [1, 1, 1], isOrthogonal: true, tpsTransformPerLayer: {}, @@ -94,7 +94,7 @@ test("Shader syntax: Arbitrary Mode (no segmentation available)", (t: ExecutionC }, orderedColorLayerNames: ["color_layer_1", "color_layer_2"], segmentationLayerNames: [], - resolutionsCount: resolutions.length, + magnificationsCount: mags.length, voxelSizeFactor: [1, 1, 1], isOrthogonal: false, tpsTransformPerLayer: {}, @@ -114,7 +114,7 @@ test("Shader syntax: Arbitrary Mode (segmentation available)", (t: ExecutionCont }, orderedColorLayerNames: ["color_layer_1", "color_layer_2"], segmentationLayerNames: ["segmentationLayer"], - resolutionsCount: resolutions.length, + magnificationsCount: mags.length, voxelSizeFactor: [1, 1, 1], isOrthogonal: false, tpsTransformPerLayer: {}, @@ -133,7 +133,7 @@ test("Shader syntax: Ortho Mode (rgb and float layer)", (t: ExecutionContext