pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
Quote:
A bounding volume hierarchy (BVH) is a tree structure on a set of geometric objects. All geometric objects are wrapped in bounding volumes that form the leaf nodes of the tree. These nodes are then grouped as small sets and enclosed within larger bounding volumes. These, in turn, are also grouped and enclosed within other larger bounding volumes in a recursive fashion, eventually resulting in a tree structure with a single bounding volume at the top of the tree.

From the wikipedia page about bvh, which is completely different from what I say.
added on the 2016-06-12 16:46:46 by golem golem
asd-romeda: so you mean tracing through regular grid?
added on the 2016-06-12 16:49:15 by tomkh tomkh
yes! But the grids are set up around each object as a box. Rays outside any boxes traverse the sdf and when they want to hit an object, they have to go through the object's grid.
So yes, triangles are listed in grids.
added on the 2016-06-12 16:53:40 by golem golem
It has been done obviously in many different variations, but can speed-up things (if implemented right). BVH can also speed-up by the way.
added on the 2016-06-12 16:57:32 by tomkh tomkh
Where? Can you name a few examples?
added on the 2016-06-12 17:01:30 by golem golem
This one is with 2d grid by iq, and is using grid id's to determine the content of the "cell".
Obviously you can also try to put content between two cells, but then you have to analyze distance to all 4 neighbours (8 in 3d) like in my experiments.
I've seen some 3d examples on shadertoy with 3d grid, but I'm lazy to search for them now. Feel free to add one :)
added on the 2016-06-12 17:06:10 by tomkh tomkh
Thanks a lot! I'll check them out.
added on the 2016-06-12 17:07:55 by golem golem
Found also this one by nimitz in 3d, but for sure there are more.
added on the 2016-06-12 17:11:08 by tomkh tomkh
Got it. Thanks
added on the 2016-06-12 17:11:52 by golem golem
Quote:
they surround and encompass only the object inside them,not each other

So basically you want to voxelize the object?
added on the 2016-06-12 17:18:52 by Gargaj Gargaj
Yes! Why didn't I say that earlier?
And then use the voxelized boxes for sdf.
added on the 2016-06-12 17:21:31 by golem golem
But isn't being more optimal than uniform voxels the point of BVH? With uniform voxels you have to be really dense with small voxels to be able to make it look nice, which means you're testing to a ton of voxels on each step during marching/tracing, even if you automatically throw out the ones that are not on the object surface. With BVH you can bail early because if your ray hits one of the bigger boxes that doesnt have any children, you can immediately acknowledge that you missed instead of having to test all the other smaller voxels too.
added on the 2016-06-12 17:28:22 by Gargaj Gargaj
Well, you can put some discretized or even procedural SDF content inside each voxel - like I believe Gavan @voxelquest is doing.
added on the 2016-06-12 17:32:06 by tomkh tomkh
well I think I'm a bit confused now...
The number of grid cells should be high for the scene to look good, but we're not setting a grid on the whole scene, just around each individual object. So much of the free space between the objects is skipped by the sdf. So doesn't this let us have higher resolution grids around each object?
added on the 2016-06-12 17:35:03 by golem golem
Tomkh: cool idea! It's the other way around to combine sdf and 3d grids (voxels). I want to put little grids inside the sdf and he's putting sdfs in little grid cells.
But it seems harder to skip much free space like that.
added on the 2016-06-12 17:44:31 by golem golem
Here's a 2D illustration of what I mean:

BB Image

On the left you have an 8x8 voxel grid with only the voxels on the edge counting - both rays have to test against all the voxels even though they both miss. That by my calculation is 32 tests per each ray, and the resolution we're getting isn't exacly great.

On the right, the red ray hits the outermost (big) box, so it tests the 4 quarters, it misses 3 and hits the fourth but the fourth doesn't have any children so it bails. The blue ray gets closer, so it has to go slightly more dense but depending on the data amount it only needs to do about ~15-20 tests to figure out it misses - but gets a much better resolution.
added on the 2016-06-12 17:51:32 by Gargaj Gargaj
Wow! That's amazing Gargaj! The best explanation of bvh I've ever heard.
And it's not against my idea. We can use bvh when it comes to checking for ray intersection in the grids, instead of simple all-the-same voxels. It can lie well in the middle of my proposal and make it faster.
added on the 2016-06-12 17:59:22 by golem golem
I forgot the 99999999999 thanks for the graphs!
added on the 2016-06-12 18:00:14 by golem golem
Yeah but then what are uniform voxels good for? You can store SDF content in a BVH too.
added on the 2016-06-12 18:21:36 by Gargaj Gargaj
Gargaj: uniform have faster look-up, especially if it's SDF.
added on the 2016-06-12 18:24:09 by tomkh tomkh
Do they though? Technically, the series of hit-tests is your lookup.
added on the 2016-06-12 18:33:34 by Gargaj Gargaj
Gargaj: after your explanation of bvh, I changed my mind actually. We don't need uniform voxels for that, bvh is better. But again, around each individual mesh.
About storing sdf content in bvh : Because we simplify the scene into a few boxes, I think the sdf can be constructed pretty fast, even without discretizing (voxelizing) the space. So there's no sdf content to store in the grids. I say this because I watched a seminar by smash
in which he talked about raytracing sdf with examples from Uncovering Static. And there was no talk about voxels for the sdf.
added on the 2016-06-12 18:38:53 by golem golem
And about the lookup thing, well I'm not professional! Those parts are completely beyond me.
added on the 2016-06-12 18:40:16 by golem golem
I guess it depends how you ray-cast through it. If you just skip empty spheres based on distance, I would say uniform will be faster, just obviously more memory consuming. If you skip empty grid cells, octree is better.
added on the 2016-06-12 18:42:28 by tomkh tomkh
Quote:
But again, around each individual mesh.

Obviously, since you probably want to animate the meshes independently :)
added on the 2016-06-12 18:42:44 by Gargaj Gargaj

login

Go to top