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.
asd-romeda: so you mean tracing through regular grid?
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.
So yes, triangles are listed in grids.
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.
Where? Can you name a few examples?
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 :)
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 :)
Thanks a lot! I'll check them out.
Found also this one by nimitz in 3d, but for sure there are more.
Got it. Thanks
Quote:
they surround and encompass only the object inside them,not each other
So basically you want to voxelize the object?
Yes! Why didn't I say that earlier?
And then use the voxelized boxes for sdf.
And then use the voxelized boxes for sdf.
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.
Well, you can put some discretized or even procedural SDF content inside each voxel - like I believe Gavan @voxelquest is doing.
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?
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?
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.
But it seems harder to skip much free space like that.
Here's a 2D illustration of what I mean:
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.
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.
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.
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.
I forgot the 99999999999 thanks for the graphs!
Yeah but then what are uniform voxels good for? You can store SDF content in a BVH too.
Gargaj: uniform have faster look-up, especially if it's SDF.
Do they though? Technically, the series of hit-tests is your lookup.
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.
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.
And about the lookup thing, well I'm not professional! Those parts are completely beyond me.
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.
Quote:
But again, around each individual mesh.
Obviously, since you probably want to animate the meshes independently :)