Twinklebear / webgl-volume-raycaster

A WebGL Volume Raycaster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My data is width 1438, height 1090, depth 100

kt7456 opened this issue · comments

commented

May I ask how to modify it so that it can be displayed correctly

What issue are you seeing? It's not scaled properly? You should be able to make a 3d texture with those dimensions, upload your data, and view it. If the scaling isn't right, try changing volScale: https://github.com/Twinklebear/webgl-volume-raycaster/blob/master/js/volume-raycaster.js#L120-L121 to rescale it properly.

commented

它没有正确缩

This data cannot be rendered correctly:
test_1438x1090x13_uint8.zip

This data renders correctly:
test_1440x1440x14_uint8.zip
1438x1090*13 file can use paraview software to render correctly:
image

1438x1090x13 file can't render correctly with code:
image
1440x1440x14 file can be rendered correctly with code:
image

first picture viewed with paraview software. second picture and third picture rendered with code. It feels that it is not as simple as modifying volscale. If the aspect ratio is not 1:1, there is no way to render it correctly, but my data width and height are not 1:1.
As you can see, the second picture is distorted, and the first and third picture they are normal

Yeah, the middle picture also looks like it may have some striding or alignment issue going on when you created the volume data, because it seems to have this shift along the rows of the image. I'd double check how you're creating the volume, maybe there is some padding or alignment rule that needs to be followed that you're not here, or you have some incorrect offset/stride/size in the volume upload code.

commented

Yeah, the middle picture also looks like it may have some striding or alignment issue going on when you created the volume data, because it seems to have this shift along the rows of the image. I'd double check how you're creating the volume, maybe there is some padding or alignment rule that needs to be followed that you're not here, or you have some incorrect offset/stride/size in the volume upload code.

Thank you so much

Something that just came to mind, in this repo I don't set the pixel store unpack alignment, so the default is 4. That might be what's causing the shift, since 1438 % 4 = 2. So you could try setting the pixel unpack alignment to 1 (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/pixelStorei)

gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
commented

Thank you very much, the problem has been solved