JuliaGL / GLVisualize.jl

Visualization library written in Julia and OpenGL
Other
247 stars 34 forks source link

Strategies for volumetric ray casting #58

Open timholy opened 8 years ago

timholy commented 8 years ago

I'm opening this as a placeholder for discussion about volumetric raycasting. My specific task is that I'll have thousands or tens of thousands of little cubical volumes, and inside each:

Typically each cube will overlap only a handful of other cubes, and much of the time most cubes will be nearly fully transparent (most p_i(t) will be near 0 most of the time).

As you know, I'm just learning OpenGL, so I can't yet produce a PR. Any guidance (even, what to read) would be appreciated. Meanwhile, I'll keep posted on progress.

SimonDanisch commented 8 years ago

Sounds like an interesting problem! Are the little cubicle volumes on a voxel grid? I'd have used instancing for the little volumes, but then every cube would be raytraced seperately. Since the handling of transparency is suboptimal outside the ray tracer (when combining the little volumes), this appraoch might not work out very well. So all the cubes should be ray traced in the same pass. If the little volumes are all on a grid, we should be able to reuse the ray tracing that is already implemented in GLVisualize (volume.frag). If not, we also need to do hit detection of the smaller volumes on the whole screen. This is definitely a bit more challenging. You can look at the examples from https://github.com/SimonDanisch/ShaderToy.jl/tree/next2, to get a feel of how some other people implemented ray tracing in the fragment shader. It might be a bit cluttered for your purpose ;)

I'll see if the people from FireRender respond and tell me how to ray trace volumes with their API.

I got going with this tutorial: http://prideout.net/blog/?p=64

timholy commented 8 years ago

Are the little cubicle volumes on a voxel grid?

Yes. Sounds like it might be best to render a complete volume image first, then do the raytracing.

You can look at the examples from https://github.com/SimonDanisch/ShaderToy.jl/tree/next2

Ooh! Did not know about this repo at all! Incredibly helpful (as always), many thanks.

SimonDanisch commented 8 years ago

Great to hear :) I just realised the install commands are outdated... If you have next2 already running, you should be fine as is!

SimonDanisch commented 8 years ago

I've updated the README for next2. Okay if they're on a grid I can create a little snippet to get you started ;) It might take until Monday though, since I'll be off the grid pretty soon! I guess it will just be a quick adaptation of the current volume tracer... You put the base alpha values in the volume texture and then create the life alpha values on the fly... For the color you could just add another texture from which you can sample.

timholy commented 8 years ago

Thanks a ton. I myself have other priorities, but I probably won't be able to entirely prevent myself from playing with ShaderToy as a fun diversion.