Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Strategies for volumetric ray casting #58

Open
timholy opened this issue Feb 17, 2016 · 5 comments
Open

Strategies for volumetric ray casting #58

timholy opened this issue Feb 17, 2016 · 5 comments

Comments

@timholy
Copy link
Contributor

timholy commented Feb 17, 2016

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:

  • each voxel has the same color c_i for the ith cubical volume
  • each voxel has a different "core" alpha value α_i(x,y,z)
  • the instantaneous alpha value changes over time uniformly throughout the cube, A_i(x,y,z,t) = α_i(x,y,z) * p_i(t).

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
Copy link
Member

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
Copy link
Contributor Author

timholy commented Feb 19, 2016

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
Copy link
Member

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

@SimonDanisch
Copy link
Member

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
Copy link
Contributor Author

timholy commented Feb 19, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants