Skip to content

Commit

Permalink
rename resolution to magnification in shader relevant code
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Büßemeyer authored and Michael Büßemeyer committed Nov 27, 2024
1 parent 6db1cbe commit 67965fa
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class PlaneMaterialFactory {
resInfo.getDenseMags(),
);
const flatMags = _.flattenDeep(allDenseMags);
this.uniforms.allResolutions = {
this.uniforms.allMagnifications = {
value: flatMags,
};

Expand All @@ -581,7 +581,7 @@ class PlaneMaterialFactory {
magCountCumSum.push(cumSum);
}

this.uniforms.resolutionCountCumSum = {
this.uniforms.magnificationCountCumSum = {
value: magCountCumSum,
};
},
Expand Down Expand Up @@ -1099,7 +1099,7 @@ class PlaneMaterialFactory {
colorLayerNames,
segmentationLayerNames,
textureLayerInfos,
resolutionsCount: this.getTotalMagCount(),
magnificationsCount: this.getTotalMagCount(),
voxelSizeFactor,
isOrthogonal: this.isOrthogonal,
tpsTransformPerLayer: this.scaledTpsInvPerLayer,
Expand Down Expand Up @@ -1134,7 +1134,7 @@ class PlaneMaterialFactory {
colorLayerNames,
segmentationLayerNames,
textureLayerInfos,
resolutionsCount: this.getTotalMagCount(),
magnificationsCount: this.getTotalMagCount(),
voxelSizeFactor,
isOrthogonal: this.isOrthogonal,
tpsTransformPerLayer: this.scaledTpsInvPerLayer,
Expand Down
20 changes: 10 additions & 10 deletions frontend/javascripts/oxalis/shaders/coords.glsl.ts
Original file line number Diff line number Diff line change
@@ -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;
}
`,
Expand Down
12 changes: 6 additions & 6 deletions frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { getMaybeFilteredColorOrFallback } from "./filtering.glsl";
import {
getAbsoluteCoords,
getResolution,
getMagnification,
getWorldCoordUVW,
isOutsideOfBoundingBox,
} from "./coords.glsl";
Expand Down Expand Up @@ -41,7 +41,7 @@ type Params = {
orderedColorLayerNames: string[];
segmentationLayerNames: string[];
textureLayerInfos: Record<string, { packingDegree: number; dataTextureCount: number }>;
resolutionsCount: number;
magnificationsCount: number;
voxelSizeFactor: Vector3;
isOrthogonal: boolean;
tpsTransformPerLayer: Record<string, TPS3D>;
Expand All @@ -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];
Expand Down Expand Up @@ -385,7 +385,7 @@ ${compileShader(
isOutsideOfBoundingBox,
getMaybeFilteredColorOrFallback,
hasSegmentation ? getSegmentId : null,
getResolution,
getMagnification,
almostEq,
)}
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions frontend/javascripts/oxalis/shaders/texture_access.glsl.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -92,7 +92,7 @@ export const getColorForCoords: ShaderModule = {
getRgbaAtIndex,
getRgbaAtXYIndex,
getAbsoluteCoords,
getResolutionFactors,
getMagnificationFactors,
hashCombine,
transDim,
],
Expand Down Expand Up @@ -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);
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions frontend/javascripts/test/shaders/shader_syntax.spec.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -27,7 +27,7 @@ test("Shader syntax: Ortho Mode", (t: ExecutionContext<any>) => {
},
orderedColorLayerNames: ["color_layer_1", "color_layer_2"],
segmentationLayerNames: [],
resolutionsCount: resolutions.length,
magnificationsCount: mags.length,
voxelSizeFactor: [1, 1, 1],
isOrthogonal: true,
tpsTransformPerLayer: {},
Expand All @@ -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: {},
Expand All @@ -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: {},
Expand All @@ -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: {},
Expand All @@ -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: {},
Expand All @@ -133,7 +133,7 @@ test("Shader syntax: Ortho Mode (rgb and float layer)", (t: ExecutionContext<any
},
orderedColorLayerNames: ["color_layer_1", "color_layer_2"],
segmentationLayerNames: [],
resolutionsCount: resolutions.length,
magnificationsCount: mags.length,
voxelSizeFactor: [1, 1, 1],
isOrthogonal: true,
tpsTransformPerLayer: {},
Expand Down

0 comments on commit 67965fa

Please sign in to comment.