Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seamless fallback #3801

Merged
merged 29 commits into from Mar 4, 2019
Merged
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ef2b759
rewrite shader code so that conversion to relative coords is done as 鈥
philippotto Feb 12, 2019
365864d
tmp: re-add fallback rendering
philippotto Feb 18, 2019
f236f1f
make seamless fallback rendering work and re-enable filtering
philippotto Feb 20, 2019
5e6f4e9
fix fallback rendering look up in non xy planes
philippotto Feb 20, 2019
6dfd92a
fix flow and linting
philippotto Feb 20, 2019
f1d950d
properly implement anisotropic fallback rendering and do some clean up
philippotto Feb 20, 2019
32401d5
remove slack reporting for crashed sagas
philippotto Feb 20, 2019
03b0e4b
improve styling of settings sidebar
philippotto Feb 20, 2019
6107800
make loading strategy configurable
philippotto Feb 20, 2019
00c9fa0
further clean up and add comments
philippotto Feb 20, 2019
5360df9
fix flycam test
philippotto Feb 20, 2019
3b86071
Merge branch 'master' of github.com:scalableminds/webknossos into sea鈥
philippotto Feb 20, 2019
278efb7
fix texture bucket manager test
philippotto Feb 21, 2019
8805ea5
fix sketchy null bug
philippotto Feb 21, 2019
8e0490a
Merge branch 'master' of github.com:scalableminds/webknossos into sea鈥
philippotto Feb 21, 2019
16e0c18
Merge branch 'master' of github.com:scalableminds/webknossos into sea鈥
philippotto Feb 25, 2019
8166d05
allow to set loading strategy via preferred task type settings
philippotto Feb 25, 2019
22bb9b3
improve code comment
philippotto Feb 25, 2019
b0d3c7b
incorporate PR feedback
philippotto Feb 25, 2019
30751dc
properly suppress non-invertible matrices warning
philippotto Feb 25, 2019
cce5fac
Merge branch 'master' of github.com:scalableminds/webknossos into sea鈥
philippotto Feb 25, 2019
8db6ec5
remove doubling viewport width in flight mode for bucket picking
philippotto Feb 25, 2019
8e3bc72
update documentation to loading strategy options and improve some oth鈥
philippotto Feb 26, 2019
2ee84c2
update changelog
philippotto Feb 26, 2019
2ad9008
add migration for loading strategy
philippotto Mar 4, 2019
6ce24f0
Merge branch 'master' of github.com:scalableminds/webknossos into sea鈥
philippotto Mar 4, 2019
5d0af02
Merge branch 'master' into seamless-fallback
daniel-wer Mar 4, 2019
0f29ba1
fix linting
philippotto Mar 4, 2019
08e6dae
Merge branch 'seamless-fallback' of github.com:scalableminds/webknoss鈥
philippotto Mar 4, 2019
File filter...
Filter file types
Jump to鈥
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -28,6 +28,11 @@ export const settings = {
crosshairSize: "Crosshair Size",
brushSize: "Brush Size",
userBoundingBox: "Bounding Box",
loadingStrategy: "Loading Strategy",
loadingStrategyDescription: `You can choose between loading the best quality first
(will take longer until you see data) or alternatively,
improving the quality progressively (data will be loaded faster,
but it will take more time until the best quality is shown).`,
};

export default {
@@ -653,6 +653,13 @@ class DataApi {
return segmentationLayer.name;
}

/**
* Invalidates all downloaded buckets so that they are reloaded on the next movement.
*/
reloadAllBuckets(): void {
_.forEach(this.model.dataLayers, dataLayer => dataLayer.cube.collectAllBuckets());
}

/**
* Sets a mapping for a given layer.
*
@@ -122,12 +122,9 @@ const VIEWPORT_WIDTH = 376;
export const ensureSmallerEdge = false;

// Using the following dimensions for the address space,
// the look up buffer (256**2) is used at a rate of ~ 97%
// ((32 脳 32 脳 50 + 16 脳 16 脳 50) / 256^2 = 0.976563)
export const addressSpaceDimensions = {
normal: [32, 32, 50],
fallback: [16, 16, 50],
};
// the look up buffer (256**2) is used at a rate of ~ 99%
This conversation was marked as resolved by philippotto

This comment has been minimized.

Copy link
@daniel-wer

daniel-wer Feb 25, 2019

Contributor

Almost 馃挴 馃憤

// ((36 脳 36 脳 50) / 256^2 = 0.98877)
export const addressSpaceDimensions = [36, 36, 50];

export const Unicode = {
ThinSpace: "\u202f",
@@ -145,8 +142,6 @@ const Constants = {
MODES_ARBITRARY: ["flight", "oblique"],
MODES_SKELETON: ["orthogonal", "flight", "oblique"],

DEFAULT_SEG_ALPHA: 20,

BUCKET_WIDTH: 32,
BUCKET_SIZE: 32 ** 3,
VIEWPORT_WIDTH,
@@ -158,7 +153,8 @@ const Constants = {
MINIMUM_REQUIRED_BUCKET_CAPACITY: 3 * 512,
LOOK_UP_TEXTURE_WIDTH: 256,

TDView_MOVE_SPEED: 150,
MAX_ZOOM_STEP_DIFF_PREFETCH: 1, // prefetch only fallback buckets for currentZoomStep + 1

MIN_MOVE_VALUE: 30,
MAX_MOVE_VALUE: 14000,
MAX_MOVE_VALUE_SLIDER: 1500,
@@ -179,8 +175,6 @@ const Constants = {
MIN_PARTICLE_SIZE: 1,
MAX_PARTICLE_SIZE: 20,

ZOOM_DIFF: 0.1,

DEFAULT_SPHERICAL_CAP_RADIUS: 140,

// !Currently disabled!
@@ -321,27 +321,22 @@ class SceneController {
// all buckets necessary for rendering are addressed. The anchorPoint is
// defined with bucket indices for the coordinate system of the current zoomStep.
let anchorPoint;
// The fallbackAnchorPoint is similar to the anchorPoint, but refers to the
// coordinate system of the next zoomStep which is used for fallback rendering.
let fallbackAnchorPoint;

const zoomStep = getRequestLogZoomStep(Store.getState());
for (const dataLayer of Model.getAllLayers()) {
[anchorPoint, fallbackAnchorPoint] = dataLayer.layerRenderingManager.updateDataTextures(
globalPosition,
zoomStep,
);
anchorPoint = dataLayer.layerRenderingManager.updateDataTextures(globalPosition, zoomStep);
This conversation was marked as resolved by philippotto

This comment has been minimized.

Copy link
@daniel-wer

daniel-wer Feb 25, 2019

Contributor

That must have been satisfying, removing all those, I'm enjoying reviewing it for sure 馃榿

}

if (optArbitraryPlane) {
optArbitraryPlane.updateAnchorPoints(anchorPoint, fallbackAnchorPoint);
optArbitraryPlane.updateAnchorPoints(anchorPoint);
optArbitraryPlane.setPosition(globalPosVec);
} else {
for (const currentPlane of _.values(this.planes)) {
currentPlane.updateAnchorPoints(anchorPoint, fallbackAnchorPoint);
currentPlane.updateAnchorPoints(anchorPoint);
currentPlane.setPosition(globalPosVec);
const [scaleX, scaleY] = getPlaneScalingFactor(state, flycam, currentPlane.planeID);
currentPlane.setScale(scaleX, scaleY);
this.displayPlane[currentPlane.planeID] = scaleX > 0 && scaleY > 0;
This conversation was marked as resolved by philippotto

This comment has been minimized.

Copy link
@daniel-wer

daniel-wer Feb 25, 2019

Contributor

So planes in the TDview are now hidden, if the tab containing that plane is scaled to be very very small?
Would you say users expect this or what is the reasoning behind that?

This comment has been minimized.

Copy link
@philippotto

philippotto Feb 25, 2019

Author Member

So planes in the TDview are now hidden, if the tab containing that plane is scaled to be very very small?

Almost :) If the viewport is hidden (happens if the tab is not active), then the scale is 0 and thus, the plane is hidden. This didn't came with this PR, but was there before. However, the problem is that threeJS complains since it tries to invert some matrix for which the determinant is zero (due to the scale being 0). This line is supposed to suppress the warning. However, I just noticed that it didn't work properly (scale needs to be non-zero, too). I just fixed that.

Would you say users expect this or what is the reasoning behind that?

I think, it's alright since nobody has complained yet. Also, I think it's plausible, since hiding a viewport (via tab organization) means that you are not really interested in it. So, hiding it in the 3d viewport as well, makes sense to me. Additionally, it's beneficial to perf :)

}
}
}
@@ -52,13 +52,10 @@ class ArbitraryPlane {
this.materialFactory.stopListening();
}

updateAnchorPoints(anchorPoint: ?Vector4, fallbackAnchorPoint: ?Vector4): void {
updateAnchorPoints(anchorPoint: ?Vector4): void {
if (anchorPoint) {
this.meshes.mainPlane.material.setAnchorPoint(anchorPoint);
}
if (fallbackAnchorPoint) {
this.meshes.mainPlane.material.setFallbackAnchorPoint(fallbackAnchorPoint);
}
}

setPosition = ({ x, y, z }: THREE.Vector3) => {
@@ -113,10 +113,6 @@ class PlaneMaterialFactory {
type: "v4",
value: new THREE.Vector3(0, 0, 0),
},
fallbackAnchorPoint: {
type: "v4",
value: new THREE.Vector3(0, 0, 0),
},
zoomStep: {
type: "f",
value: 1,
@@ -187,11 +183,7 @@ class PlaneMaterialFactory {
},
addressSpaceDimensions: {
type: "v3",
value: new THREE.Vector3(...addressSpaceDimensions.normal),
},
addressSpaceDimensionsFallback: {
type: "v3",
value: new THREE.Vector3(...addressSpaceDimensions.fallback),
value: new THREE.Vector3(...addressSpaceDimensions),
},
};

@@ -290,10 +282,6 @@ class PlaneMaterialFactory {
this.uniforms.anchorPoint.value.set(x, y, z);
};

this.material.setFallbackAnchorPoint = ([x, y, z]) => {
this.uniforms.fallbackAnchorPoint.value.set(x, y, z);
};

this.material.setSegmentationAlpha = alpha => {
this.uniforms.alpha.value = alpha / 100;
};
@@ -3,23 +3,22 @@ import * as THREE from "three";

import UpdatableTexture from "libs/UpdatableTexture";

export const channelCountToFormat = {
"1": THREE.LuminanceFormat,
"2": THREE.LuminanceAlphaFormat,
"3": THREE.RGBFormat,
"4": THREE.RGBAFormat,
};

// This function has to be in its own file as non-resolvable cycles are created otherwise
export function createUpdatableTexture(
width: number,
channelCount: number,
type: THREE.FloatType | THREE.UnsignedByteType | THREE.Uint32BufferAttribute,
renderer: THREE.WebGLRenderer,
): UpdatableTexture {
let format;
if (channelCount === 1) {
format = THREE.LuminanceFormat;
} else if (channelCount === 2) {
format = THREE.LuminanceAlphaFormat;
} else if (channelCount === 3) {
format = THREE.RGBFormat;
} else if (channelCount === 4) {
format = THREE.RGBAFormat;
} else {
const format = channelCountToFormat[channelCount];
if (!format) {
throw new Error(`Unhandled byte count: ${channelCount}`);
}

@@ -3,7 +3,7 @@ import * as THREE from "three";
import _ from "lodash";
import memoizeOne from "memoize-one";

import type { Flycam, OxalisState } from "oxalis/store";
import type { Flycam, LoadingStrategy, OxalisState } from "oxalis/store";
import { M4x4, type Matrix4x4 } from "libs/mjs";
import { ZOOM_STEP_INTERVAL } from "oxalis/model/reducers/flycam_reducer";
import { clamp, map3 } from "libs/utils";
@@ -18,13 +18,14 @@ import constants, {
type Vector3,
type ViewMode,
} from "oxalis/constants";
import determineBucketsForOrthogonal from "oxalis/model/bucket_data_handling/bucket_picker_strategies/orthogonal_bucket_picker";
import determineBucketsForFlight from "oxalis/model/bucket_data_handling/bucket_picker_strategies/flight_bucket_picker";
import determineBucketsForOblique from "oxalis/model/bucket_data_handling/bucket_picker_strategies/oblique_bucket_picker";
import determineBucketsForOrthogonal from "oxalis/model/bucket_data_handling/bucket_picker_strategies/orthogonal_bucket_picker";
import * as scaleInfo from "oxalis/model/scaleinfo";

function calculateTotalBucketCountForZoomLevel(
viewMode: ViewMode,
loadingStrategy: LoadingStrategy,
datasetScale: Vector3,
resolutions: Array<Vector3>,
logZoomStep: number,
@@ -39,7 +40,6 @@ function calculateTotalBucketCountForZoomLevel(
// Define dummy values
const position = [0, 0, 0];
const anchorPoint = [0, 0, 0, 0];
const fallbackAnchorPoint = [0, 0, 0, 0];
const subBucketLocality = [1, 1, 1];
const sphericalCapRadius = constants.DEFAULT_SPHERICAL_CAP_RADIUS;

@@ -76,9 +76,9 @@ function calculateTotalBucketCountForZoomLevel(
determineBucketsForOrthogonal(
resolutions,
enqueueFunction,
loadingStrategy,
logZoomStep,
anchorPoint,
fallbackAnchorPoint,
areas,
subBucketLocality,
abortLimit,
@@ -101,6 +101,7 @@ function calculateTotalBucketCountForZoomLevel(
// This function is only exported for testing purposes
export function _getMaximumZoomForAllResolutions(
viewMode: ViewMode,
loadingStrategy: LoadingStrategy,
datasetScale: Vector3,
resolutions: Array<Vector3>,
viewportRects: OrthoViewRects,
@@ -129,6 +130,7 @@ export function _getMaximumZoomForAllResolutions(
const nextZoomValue = maxZoomValue * ZOOM_STEP_INTERVAL;
const nextCapacity = calculateTotalBucketCountForZoomLevel(
viewMode,
loadingStrategy,
datasetScale,
resolutions,
currentResolutionIndex,
@@ -196,6 +198,7 @@ export function getRequestLogZoomStep(state: OxalisState): number {
const { viewMode } = state.temporaryConfiguration;
const maximumZoomSteps = getMaximumZoomForAllResolutions(
viewMode,
state.datasetConfiguration.loadingStrategy,
state.dataset.dataSource.scale,
getResolutions(state.dataset),
getViewportRects(state),
@@ -222,6 +225,7 @@ export function getMaxZoomValue(state: OxalisState): number {

const maximumZoomSteps = getMaximumZoomForAllResolutions(
viewMode,
state.datasetConfiguration.loadingStrategy,
state.dataset.dataSource.scale,
getResolutions(state.dataset),
getViewportRects(state),
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.