[Bug] vtkImageCPRMapper: the shader receives the uniform orientation without conversion
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
Đọc Sources/Rendering/OpenGL/ImageCPRMapper/index.js quanh dòng 1230 và Sources/Rendering/WebGPU/ImageCPRMapper/index.js quanh dòng 682, sau đó lần theo vị trí CPU chuyển đổi các định dạng orientation thành quaternion. Kiểm tra các bài kiểm thử ImageCPRMapper hiện có để tìm chỗ bổ sung trường hợp cho đầu vào quaternion, mat4, mat3 và vec3. Hoàn thành khi mỗi định dạng orientation được hỗ trợ đều tạo ra cùng một hướng lấy mẫu trong cả hai mapper.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug description
The mapper accepts a uniform orientation as a quaternion, a mat4, a mat3 or a
vec3. The CPU side converts these values to a quaternion. But
Sources/Rendering/OpenGL/ImageCPRMapper/index.js:1230 sends
getUniformOrientation() to the vec4 shader uniform without conversion.
The WebGPU mapper (Sources/Rendering/WebGPU/ImageCPRMapper/index.js:682)
does the same. A mat4, mat3 or vec3 orientation gives a wrong sampling
direction.
Steps to reproduce
- Run this code:
import '@kitware/vtk.js/Rendering/Profiles/All';
import { mat4, quat } from 'gl-matrix';
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
import vtkImageCPRMapper from '@kitware/vtk.js/Rendering/Core/ImageCPRMapper';
import vtkImageSlice from '@kitware/vtk.js/Rendering/Core/ImageSlice';
import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer';
import vtkRenderWindow from '@kitware/vtk.js/Rendering/Core/RenderWindow';
// Render a CPR along z and return the red values of the middle row.
function renderMiddleRow(orientation) {
// The value increases along y only.
const values = new Float32Array(64);
for (let i = 0; i < 64; i++) {
values[i] = Math.floor(i / 4) % 4;
}
const image = vtkImageData.newInstance();
image.setDimensions(4, 4, 4);
image.getPointData().setScalars(vtkDataArray.newInstance({ values }));
const centerline = vtkPolyData.newInstance();
centerline.getPoints().setData(new Float32Array([1.5, 1.5, 0, 1.5, 1.5, 3]), 3);
centerline.getLines().setData(new Uint16Array([2, 0, 1]));
const mapper = vtkImageCPRMapper.newInstance();
mapper.setUseUniformOrientation(true);
mapper.setUniformOrientation(orientation);
mapper.setImageData(image);
mapper.setCenterlineData(centerline);
mapper.setWidth(3);
const actor = vtkImageSlice.newInstance();
actor.setMapper(mapper);
actor.getProperty().setColorWindow(3);
actor.getProperty().setColorLevel(1.5);
const renderer = vtkRenderer.newInstance();
renderer.addActor(actor);
const renderWindow = vtkRenderWindow.newInstance();
renderWindow.addRenderer(renderer);
const glWindow = renderWindow.newAPISpecificView('WebGL');
glWindow.setContainer(document.body.appendChild(document.createElement('div')));
glWindow.setSize(16, 16);
renderWindow.addView(glWindow);
renderer.resetCamera();
renderWindow.render();
return Array.from(glWindow.getPixelData(0, 8, 15, 8).filter((v, i) => i % 4 === 0));
}
// The same rotation of 90 degrees about z, as a quaternion and as a mat4.
const q = quat.setAxisAngle(quat.create(), [0, 0, 1], Math.PI / 2);
const m = mat4.fromRotation(mat4.create(), Math.PI / 2, [0, 0, 1]);
console.log('quat', renderMiddleRow(Array.from(q)).join(' '));
console.log('mat4', renderMiddleRow(Array.from(m)).join(' '));
Detailed Behavior
The output is:
quat 0 0 0 0 3 26 50 73 97 120 144 167 191 107 0 0
mat4 0 0 0 85 85 85 85 85 85 85 85 85 85 43 0 0
The quaternion samples along y and shows the gradient. The mat4 is the same
rotation, but the row is constant: the shader samples along a wrong direction.
Expected Behavior
The shader receives the converted quaternion. All the orientation formats
give the same image.
Environment
- vtk.js version: master (
67328bc3ef) - Browsers: Chromium (Playwright, Vitest 5 browser mode), WebGL2
- OS: Windows 11
- Ngôn ngữ chính
- JavaScript
- Star
- 1.5k
- Fork
- 428
- Merge trung bình
- 5 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Kitware/vtk-js
-
type: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
type: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
type: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] vtkTransform: transformNormals and transformVectors do not mark the output as modifiedĐang mởtype: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
type: bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của Kitware/vtk-js
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
andromarces/agent-loops#1735 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Undo after deleting a todoĐang mởenhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
BinaryBaconLabs/todo-app#32 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing assertions to legacy Cafe Menu block testsCó thể đã có người làm @mariamanbar đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
freeCodeCamp/freeCodeCamp#71624 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
JSPrismarine/JSPrismarine#2915 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
posthog
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DobermanCore/Doberman-Core#791 ·
Maintainer thường phản hồi trong vòng 3 ngày