Twinklebear / webgl-volume-raycaster

A WebGL Volume Raycaster
MIT License
252 stars 30 forks source link

How to slice the model? #9

Closed kt7456 closed 1 year ago

kt7456 commented 1 year ago

How to slice the model?

Twinklebear commented 1 year ago

Do you mean in general? Or in WebGL? If you want to just see a slice you could use ParaView: https://forgeanalytics.io/blog/creating-slices-in-paraview/ .

If you want to do it in WebGL, you can create a plane geometry that you render inside the volume coordinates and then in the fragment shader you can look up the 3D texture value to color it by. That will let you efficiently compute arbitrarily oriented slice planes, since the plane values are computed on the fly by sampling the 3D texture.

kt7456 commented 1 year ago

in WebGL ,but i dont know how to do

Twinklebear commented 1 year ago

So then you would do as I described above w/ the plane geometry. The points on the plane exist in the volume coordinate space (or are transformed into it from the world space), these are your 3D texture coordinates to sample from the volume texture to get values for the cutting plane