opened
haehn
username_0
Hi @username_1 and @rudolphpienaar 

It's final project time in my CS460.org Graphics course :) One student wants to implement volume rendering for OpenAnatomy.org. Now, we uses the brain atlas T1 nrrd file from there and the volume rendering example in AMI. The initial loading/parsing of the NRRD file takes super long and even stalls the browser (latest firefox) with a warning. If we drag the same NRRD file into slicedrop, loading is instant. Do you know why?

Thank you!
loading/parsing of NRRD files very slow
issue
created
NicolasRannou
username_1
Hi @username_0, sorry, I'm not much online those days!

Yes, there should be almost no difference with Slicedrop!

Do you know which kind of data (binary, uint, etc) and the approximate dimensions of the volume you are trying to load?

The way it currently works in AMI (as far as I can remember):
1- Load the data from the server
2- Parse data (https://github.com/FNNDSC/ami/blob/master/src/parsers/parsers.nrrd.js)
3- Store parsed data in typed array(s) - 1 per frame as far as I can remember (https://github.com/FNNDSC/ami/blob/master/src/parsers/parsers.nrrd.js)
4- Pack the typed arrays into 2d textures that are passed to the shaders

I'm not too sure how much time and how experienced the students are but I would:
1 (most important)- Profile the code to see where is the bottleneck (I'm assuming 3 and 4 are)
2- Consider using web-workers somehow
3- Consider WebGL2 Sampler2DArray (or 3d textures but it seems Sampler2DArray lets you upload single frames without re-uploading the whole stack to the shaders - not tested -)
4- Use the data loader from AMI (assuming bottleneck is not there) then write a custom ThreeJS "Shader Material" that doesn't require the image data to be packed!
5- Use XTK for non-webgl2 devices and implement a fast WebGL2 version (possibly leveraging the XTK NRRD parsers?)

Right now, AMI is very big and takes a lot of time to maintain so I'm considering splitting it into smaller "plugins for threejs", maybe under a mono-repo. One of the plugins could be "NRRD Loader", another "VolumeRendering2 Material", then the user does the "plumbing" to create the "NRRD Volume Rendering application".

I still use AMI every day but I seem to keep re-using and avoiding some components to allow me to get where we want it to be! 

Let's chat soon it has been too long!
comment