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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - CDF in invlerp if only 3D view shown of image layer #592

Merged
merged 44 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a79e6be
refactor: move histogram shader code to cdf.ts
seankmartin May 14, 2024
c326b7b
Revert "refactor: move histogram shader code to cdf.ts"
seankmartin May 14, 2024
1b1b731
feat: grab global histogram specs from VR layer
seankmartin May 14, 2024
dc621ee
temp: clear all histogram buffers as demo
seankmartin May 14, 2024
42c0219
feat: use VR layer visibility to also control hist showing
seankmartin May 14, 2024
3e8e46f
feat: only do VR hist drawing if no slice views
seankmartin May 14, 2024
ecf2cef
temp: shader for 3d invlerp
seankmartin May 14, 2024
448f277
temp: more progress
seankmartin May 14, 2024
b5ccff6
temp: minimal shader to debug with
seankmartin May 14, 2024
b62c8cb
revert: remove in vertex
seankmartin May 15, 2024
3043740
temp: compiling vertex shader for data access
seankmartin May 15, 2024
aca897a
temp: simple buffer output hist
seankmartin May 15, 2024
f6b231c
fix: volume chunks work ok
seankmartin May 15, 2024
01574db
fix: working hist for one chunk
seankmartin May 15, 2024
034be6d
fix: drawing works but very slow. Multi-pass probably better but then…
seankmartin May 15, 2024
ce05ebf
fix: working histogram 3d
seankmartin May 15, 2024
6d1db25
fix: histogram data display of off invlerp range
seankmartin May 15, 2024
04828d8
feat: work towards multi-channel multi-invlerp support
seankmartin May 16, 2024
17eab67
fix: VR tool from Python
seankmartin May 16, 2024
4b1e654
fix: VR sample works for multi-invlerp
seankmartin May 16, 2024
ae7bf33
fix: VR max projection works with data sampling
seankmartin May 16, 2024
3370b78
feat: add ability to only activate chunk textures
seankmartin May 16, 2024
99c939c
fix: more error checking in VR layer for histograms
seankmartin May 16, 2024
93c592e
chore: add comment
seankmartin May 16, 2024
d8e414c
feat: detect camera move in perspective panel
seankmartin May 20, 2024
c302233
refactor: rename code snippets in chunk
seankmartin May 20, 2024
b29b501
refactor: rename variable
seankmartin May 20, 2024
d3b274b
refactor: clarify volume rendering code with histograms
seankmartin May 20, 2024
537be3a
fix: change histogram debug default to false
seankmartin May 20, 2024
706be23
fix: correct fragment shader for regular chunk render
seankmartin May 20, 2024
e53325e
chore: add comment
seankmartin May 20, 2024
951f6e3
Merge branch 'master' into feature/histogram-in-vr-invlerp
seankmartin May 20, 2024
b7aac11
feat: allow render context to know camera move
seankmartin May 20, 2024
8b58e74
debug: add frame rate monitor to help compare performance
seankmartin May 21, 2024
645df6c
debug: track time for VR render
seankmartin May 21, 2024
c85a779
feat: faster histogram rendering by avoiding shader and buffer flippign
seankmartin May 21, 2024
31ff284
Merge branch 'feature/detect-camera-movement-perspective-panel' into …
seankmartin May 21, 2024
1298951
feat: don't render 3d histogram if camera movement
seankmartin May 21, 2024
dc9276f
refactor: clarify chunk info storage for histograms
seankmartin May 22, 2024
3fc067d
feat: variable samples for each histogram based on size and chunk amount
seankmartin May 22, 2024
7226cf0
refactor: clean up for review
seankmartin Jun 3, 2024
3b7c241
refactor: improve vertex shader tabbing
seankmartin Jun 3, 2024
5b68ae0
Merge branch 'master' into feature/histogram-in-vr-invlerp
seankmartin Jun 3, 2024
2ebc60f
fix: re-enable depth test on restore buffers
seankmartin Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/perspective_view/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ import { MultipleScaleBarTextures } from "#src/widget/scale_bar.js";
import type { RPC } from "#src/worker_rpc.js";
import { SharedObject } from "#src/worker_rpc.js";

const REDRAW_DELAY_AFTER_CAMERA_MOVE = 300;

export interface PerspectiveViewerState extends RenderedDataViewerState {
wireFrame: WatchableValueInterface<boolean>;
orthographicProjection: TrackableBoolean;
Expand Down Expand Up @@ -251,6 +253,7 @@ export class PerspectivePanel extends RenderedDataPanel {
protected visibleLayerTracker: Owned<
VisibleRenderLayerTracker<PerspectivePanel, PerspectiveViewRenderLayer>
>;
private redrawAfterMoveTimeOutId: number = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use lodash debounce for this


get rpc() {
return this.sharedObject.rpc!;
Expand All @@ -261,6 +264,9 @@ export class PerspectivePanel extends RenderedDataPanel {
get displayDimensionRenderInfo() {
return this.navigationState.displayDimensionRenderInfo;
}
get isCameraMoving() {
return this.redrawAfterMoveTimeOutId !== -1;
}

/**
* If boolean value is true, sliceView is shown unconditionally, regardless of the value of
Expand Down Expand Up @@ -417,6 +423,22 @@ export class PerspectivePanel extends RenderedDataPanel {
this,
);

this.registerDisposer(
this.viewer.navigationState.changed.add(() => {
// Don't mark camera moving on picking requests
if (this.isMovingToMousePosition) {
return;
}
if (this.redrawAfterMoveTimeOutId !== -1) {
window.clearTimeout(this.redrawAfterMoveTimeOutId);
}
this.redrawAfterMoveTimeOutId = window.setTimeout(() => {
this.redrawAfterMoveTimeOutId = -1;
this.context.scheduleRedraw();
}, REDRAW_DELAY_AFTER_CAMERA_MOVE);
}),
);

registerActionListener(
element,
"rotate-via-mouse-drag",
Expand Down Expand Up @@ -902,6 +924,8 @@ export class PerspectivePanel extends RenderedDataPanel {
alreadyEmittedPickID: false,
bindFramebuffer,
frameNumber: this.context.frameNumber,
sliceViewsPresent: this.sliceViews.size > 0,
cameraMovementInProgress: this.isCameraMoving,
};

mat4.copy(
Expand Down Expand Up @@ -987,6 +1011,7 @@ export class PerspectivePanel extends RenderedDataPanel {
};
gl.depthMask(true);
bindMaxProjectionBuffer();
renderContext.bindMaxProjectionBuffer = bindMaxProjectionBuffer;
gl.clearColor(0.0, 0.0, 0.0, 0.0);
gl.clearDepth(0.0);
gl.clear(
Expand Down
15 changes: 15 additions & 0 deletions src/perspective_view/render_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ export interface PerspectiveViewRenderContext
* Specifies the ID of the depth frame buffer texture to query during rendering.
*/
depthBufferTexture?: WebGLTexture | null;

/**
* Specifies if there are any slice views
*/
sliceViewsPresent: boolean;

/**
* Specifies if the camera is moving
*/
cameraMovementInProgress: boolean;

/**
* Specifices how to bind the max projection buffer
*/
bindMaxProjectionBuffer?: () => void | undefined;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
Expand Down
3 changes: 3 additions & 0 deletions src/rendered_data_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export abstract class RenderedDataPanel extends RenderedPanel {
pickRequestPending = false;

private mouseStateForcer = () => this.blockOnPickRequest();
protected isMovingToMousePosition: boolean = false;

inputEventMap: EventActionMap;

Expand Down Expand Up @@ -616,7 +617,9 @@ export abstract class RenderedDataPanel extends RenderedPanel {
registerActionListener(element, "move-to-mouse-position", () => {
const { mouseState } = this.viewer;
if (mouseState.updateUnconditionally()) {
this.isMovingToMousePosition = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in the meeting, it would be better for this to be more global than a single RenderedDataPanel

this.navigationState.position.value = mouseState.position;
this.isMovingToMousePosition = false;
}
});

Expand Down
34 changes: 21 additions & 13 deletions src/sliceview/uncompressed_chunk_format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ export class ChunkFormat
);
}

defineShader(builder: ShaderBuilder, numChannelDimensions: number) {
defineShader(
builder: ShaderBuilder,
numChannelDimensions: number,
inVertexShader: boolean = false,
) {
super.defineShader(builder, numChannelDimensions);
const { textureDims } = this;
const textureVecType = `ivec${this.textureDims}`;
Expand All @@ -153,35 +157,39 @@ export class ChunkFormat
"uVolumeChunkStrides",
4 + numChannelDimensions,
);
builder.addFragmentCode(
textureAccessHelper.getAccessor(
"readVolumeData",
"uVolumeChunkSampler",
this.dataType,
),
const textureSamplerCode = textureAccessHelper.getAccessor(
"readVolumeData",
"uVolumeChunkSampler",
this.dataType,
);
const shaderType = getShaderType(this.dataType);
let code = `
let dataAccessCode = `
${shaderType} getDataValueAt(highp ivec3 p`;
for (let channelDim = 0; channelDim < numChannelDimensions; ++channelDim) {
code += `, highp int channelIndex${channelDim}`;
dataAccessCode += `, highp int channelIndex${channelDim}`;
}
code += `) {
dataAccessCode += `) {
highp ${textureVecType} offset = uVolumeChunkStrides[0]
+ p.x * uVolumeChunkStrides[1]
+ p.y * uVolumeChunkStrides[2]
+ p.z * uVolumeChunkStrides[3];
`;
for (let channelDim = 0; channelDim < numChannelDimensions; ++channelDim) {
code += `
dataAccessCode += `
offset += channelIndex${channelDim} * uVolumeChunkStrides[${4 + channelDim}];
`;
}
code += `
dataAccessCode += `
return readVolumeData(offset);
}
`;
builder.addFragmentCode(code);
if (inVertexShader) {
builder.addVertexCode(textureSamplerCode);
builder.addVertexCode(dataAccessCode);
} else {
builder.addFragmentCode(textureSamplerCode);
builder.addFragmentCode(dataAccessCode);
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/sliceview/volume/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export interface ChunkFormat {
*
* where value_type is `getShaderType(this.dataType)`.
*/
defineShader: (builder: ShaderBuilder, numChannelDimensions: number) => void;
defineShader: (
builder: ShaderBuilder,
numChannelDimensions: number,
inVertexShader?: boolean,
) => void;

/**
* Called once per RenderLayer when starting to draw chunks, on the ChunkFormat of the first
Expand Down
Loading
Loading