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

Refactor RgbVis with shader #969

Merged
merged 2 commits into from
Feb 16, 2022
Merged

Refactor RgbVis with shader #969

merged 2 commits into from
Feb 16, 2022

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented Feb 15, 2022

Driven by the deprecation of RGBFormat #962 and the optimisation of the BGR flip.

An RGB image is represented as an array of size [rows, cols, 3], where the three values in the last dimension are for the red, green and blue channels (or blue, green and red). There's no alpha values, so if we want to use the typed array returned by the back-end provider as is, without looping through it (for performance reasons), we can't just switch to RGBAFormat.

So instead, we use a 3D texture with REDFormat and access each color component in a custom fragment shader with the texture() function. Three's DataTexture3D is still under development, so we have to set the format and type manually: https://github.com/mrdoob/three.js/blob/master/src/textures/DataTexture3D.js

The cast/conversion to a compatible texture type remains the same as before.

The BGR flip is now done in the shader -- we no longer call createArrayFromView.

image

packages/lib/src/vis/heatmap/HeatmapVis.tsx Show resolved Hide resolved
packages/lib/src/vis/heatmap/models.ts Show resolved Hide resolved
packages/lib/src/vis/rgb/RgbMesh.tsx Show resolved Hide resolved
packages/lib/src/vis/rgb/utils.ts Show resolved Hide resolved
packages/lib/src/vis/rgb/RgbMesh.tsx Show resolved Hide resolved
packages/lib/src/vis/rgb/RgbMesh.tsx Show resolved Hide resolved
packages/lib/src/vis/rgb/utils.ts Show resolved Hide resolved
packages/lib/src/vis/rgb/RgbMesh.tsx Outdated Show resolved Hide resolved
@axelboc axelboc merged commit e96284c into main Feb 16, 2022
@axelboc axelboc deleted the rgb-shader branch February 16, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants