Advertisement Jump to content
Sign in to follow this  
Pathering

Uniform grid traversal

This topic is 1762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone,

I wrote a simple ray tracer and I would like to improve it by creating grids. First, I want to create a uniform grid to accelerate the rendering. Right now, I have my triangles in my grid but I am stuck because I don't understand how to traverse it....

I found a tutorial which gives some code to traverse this kind of grid : http://www.clockworkcoders.com/oglsl/rt/gpurt3.htm.
I don't really understand so I am asking you some help.

I understand that I have to find the vessel where the ray is starting, but how can I know which is the next voxel ?

Share this post


Link to post
Share on other sites
Advertisement

the ray starts to intersect a wall of a box and exists another wall of that box. Do some ray to plan intersection, determine if its the left up down etc wall, from there you know the next box this ray is going to go into.

Share this post


Link to post
Share on other sites

So, I have to compute an intersection of the ray with all the planes of the box ? and for all boxes the ray intersects ?

Share this post


Link to post
Share on other sites

I don't know everything off the top of my head. I would assume you can get more detailed information if you search for ray tracing bsp uniform grid or something. That link doesn't look very helpful.

Share this post


Link to post
Share on other sites

Thanks for the link. I understand better the algorithm. smile.png

 

You're welcome. Me I think that the 3D DDA is very important but it's not that trivial to understand from a point of view of precision (when exactly to read/write into a not before visited cell) and a simple +- or rounding error wrong and your are a bit off. Sometime I wish floating point numbers were no more and we all went back to using fixed point math as floats are just so inaccurate, but that's another tangent :-)

Edited by jbadams
Restored post contents from history.

Share this post


Link to post
Share on other sites

One more question about the algorithm happy.png

In the paper it said : 

 

Next, we determine the value of t at which the ray crosses the ?rst vertical voxel boundary and

store it in variable tMaxX. We perform a similar computation in y and store the result in tMaxY. The
minimum of these two values will indicate how much we can travel along the ray and still remain in the
current voxel

 I think to intersect each plane of the grids (for X, Y and Z), but it seems greedy to compute. Is there a faster method ?

Share this post


Link to post
Share on other sites

I said anything...

I know the voxel where the ray starts. Also I know stepx, stepY and stepZ (1 if the ray coordinate is positive -1 otherwise).

Thanks to that I know the equation of my planes : for example if stepX is 1, the equation of my plane is P = minX (minX and maxX are my boundaries of the voxel for X), and if stepX is -1, the equation of my plane is P = maxX.

Same things for y and z.

 

Is it correct ?

Share this post


Link to post
Share on other sites

Maybe it's an idea to write your code in such a way that you can later change it into using octrees. Because ray-tracing in sparse voxel octrees can even be done in real-time. smile.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!