2
$\begingroup$

So Im trying to implement a Volume Renderer mainly for medical images like CT-scans and MRI images using GPU raymarching. I'm using the book "Real Time Volume Graphics" and this tutorial as a refernce.

I'm trying to render only grayscale images as a start. I understand that the pvm2raw part gives us an 8-bit raw file so each voxel has the isovalue in the range [0-255]. So I decided map this single value on all color channels rgba when taking a sample.

I am taking the datasets from here. You can see my Renderer's result in this video (check the end of my post and sorry for not providing a direct link as I already uploaded on my reddit post)

As you can see the lobster dataset stretches when viewed from the side. My first guess was that I wasn't accounting for the aspect ratio correctly. I have tried scaling the Bounding box to account for the aspect ratio, then adjusting the stepsize according to that. I've also tried to ignore aspect ratio altogether. Both give similar images.

I tried rendering more datasets like "Knee", "Bruce's head", "DTI Scan", etc but those didn't even gave an image. There was just random noise everywhere. Here's an example of "Bruce's head"

enter image description here

This happens with both uniform and non-uniform datasets. If some datasets are getting rendered correctly like the "Foot" in my video, this should mean it's more a with that specific dataset itself rather the core algorithm. Nonetheless the link to the code is provided If anybody can point out some mistakes I'd be grateful.

The link to the Compute shader is here. Main functions are rayMarchVolume. I didn't scale the root bounding box to the dimensions of the volume, it's normalized (0-1), accounted for the aspect ratio (0, ar) and adjusted so it's in the center (-ar/2, ar/2). The function cartesianToTextureCoord(vec4 point) accounts for this fact and returns a texture coord in the range 0-1

EDIT:- If you are hesitating to post an answer here since it's only a suggestion, you can post on Reddit, then when the problem is solved you can post your answer here

UPDATE:- I've provided a release to this project on github. If anybody is willing to help me with this, he can download the release and run the program. Since the algorithm is based entirely inside the compute shader you can change the file easily and test your findings on the spot. Thanks.

$\endgroup$
2
  • $\begingroup$ You are computing the ray direction in camera space, but the ray origin is in world space? eye_ray.dir = normalize(vec4(x,y,z,0)); eye_ray.dir = normalize((main_cam.view_mat * vec4(eye_ray.dir))); eye_ray.origin = main_cam.eye; $\endgroup$ – Nadir Aug 22 '19 at 7:02
  • $\begingroup$ @Nadir - no actually the view mat, sorry for the poor naming, is actually the view2world_mat so it converts the direction from camera space to world space. $\endgroup$ – gallickgunner Aug 22 '19 at 7:37
0
$\begingroup$

Sorry to post such a silly solution but apparently the problem was reading 16 bit uint data into 8bit uint array. This was the reason for inexplainable noise, interleaving and other artifacts.

After I explored more about what the medical datasets actually represent and what flavors they come in (8,16,32bit) I managed to solve the problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.