Comments on: Implementing Morton ordering for chunked voxel data http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/ Voxel-based games and technology Tue, 11 Aug 2020 06:19:17 +0000 hourly 1 https://wordpress.org/?v=4.9.3 By: David Williams http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-120056 Wed, 07 Oct 2015 22:02:05 +0000 http://www.volumesoffun.com/?p=1755#comment-120056 I’m not sure I fully understand your concerns. You are concerned about the distance (in memory?) between voxels in different chunks? Actually we do not store the chunks continuously anyway (they are spread out in memory) so I don’t expect this makes much difference. Of course, it may be interesting to organise the chunks differently but that’s not the issue we are addressing here.

As for the performance, well overall there is not a big difference but the Morton version may be slightly faster. I think the main reason it is interesting is that it makes some other operations easier such as downsampling the volume data.

But really I’m just giving information on how you implement this scheme. Whether you actually want to may depend on your exact use case.

]]>
By: d3x0r http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-120012 Wed, 07 Oct 2015 08:33:32 +0000 http://www.volumesoffun.com/?p=1755#comment-120012 This is actually a terrible idea.
It seems like a good idea, but at 31,31,31 the distance between near sectors is huge. 32*32 is only 1024, whereas the min-max range covered from near voxels is 196616. which will cover several pages of memory.

It looks good at low values, the distance from (-1,-1,-1) to (1,1,1) around 7,7,7 is only 3080 (still more than the 2048+ a little it would require)… so okay
at 1,1,1 the distance is only 56. But as the values increase so does the distance spanned in memory.
doing 1,1,1 to 32,32,32 the average is 14336 min/max range.

Having reasonably sized sectors (16x16x64 or even 32x32x32) is more likely to have near values cached. It also complicates the indexing between sectors for near points.

]]>
By: David Williams http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109278 Mon, 20 Apr 2015 07:48:15 +0000 http://www.volumesoffun.com/?p=1755#comment-109278 Well thanks for the snippet (and sorry for not crediting you – I’ve added a link to your GitHub repo to the blog post now)!

I think we need to do some more tests with these lookup tables vs. computing the offset at run time with the tricks you describe. I do agree that the calculations should be faster in principle due to touching less memory. It’s surprisingly difficult to test these things accurately though.

]]>
By: Alexandre Avenel http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109238 Sun, 19 Apr 2015 21:09:48 +0000 http://www.volumesoffun.com/?p=1755#comment-109238 Hi David,

Thanks for your blog post, very interesting !
I’m the original author of the code you link for generating Morton offsets at compile time (https://github.com/aavenel/FastMortonKeys/blob/master/mortonkeys.h).
However, I’m not very proud of this, and it’s possible to implement this in a much easier way :/
I agree with Fabian comment, only one table should be better.

If you want, I have some code snippet for additionning morton-encoded coordinates in xyz form, you can have a look here :
https://gist.github.com/aavenel/a5349516aa33b7499eef

]]>
By: David Williams http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109186 Sun, 19 Apr 2015 06:07:21 +0000 http://www.volumesoffun.com/?p=1755#comment-109186 For future readers this must be the stuff you are referring to: http://bitmath.blogspot.nl/2012/11/tesseral-arithmetic.html

It looks like really cool stuff. You and Fabian Giesen have got me thinking again about computing some of this on the fly (rather than using the lookup tables) as in principle such bitwise operations are supposed to be faster than memory accesses.

]]>
By: David Williams http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109185 Sun, 19 Apr 2015 06:03:25 +0000 http://www.volumesoffun.com/?p=1755#comment-109185 Overall we’re not seeing a big change in performance – the extra cost of Morton calculations is balanced by improved memory access time (or something else is the bottleneck). But the interesting point is that if Morton is no more expensive then we get the other benefits of it (better compression, easier downsampling, etc) for free.

Edit: Maybe that was too negative. Here I said “The tests which are very heavy on sampler access show a 40-50% increase , but practical algorithms such as the Marching Cubes extractor show only a few % increase.”

I think overall it is worth it, but your mileage may vary 🙂

]]>
By: David Williams http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109184 Sun, 19 Apr 2015 06:01:36 +0000 http://www.volumesoffun.com/?p=1755#comment-109184 Thanks a lot, I really appreciate the feedback. I think I’ll try doing (at least some of) the calculations on the fly and see how it compares.

]]>
By: Fabian Giesen http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109163 Sat, 18 Apr 2015 21:21:51 +0000 http://www.volumesoffun.com/?p=1755#comment-109163 To increment one axis value if you already have the Morton offset, the math is pretty hard to beat. (Computing those table offsets takes arithmetic operations too!)

For the rest it depends; a small table is certainly not bad.

One thing that might be useful for you is that morton256_y[i] = morton256_x[i] << 1 and morton256_z[i] = morton256_x[i] << 2, and the same goes for the delta tables. So you can reduce the amount of tables you store (and cache misses you might incur accessing them!) by a factor of 3 for the cost of 2 bit shifts per access, which is a pretty good deal.

]]>
By: Harold http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109158 Sat, 18 Apr 2015 19:22:53 +0000 http://www.volumesoffun.com/?p=1755#comment-109158 I’m that guy from the “add Morton coordinates” stackoverflow answer, it can be done quite efficiently (see below the hline). I also wrote a bunch more about it, like taking the minimum (and max, which is of course essentially the same), increment and increment with saturation, google “tesseral arithmetic”. Probably more can be done.

]]>
By: fenbf http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comment-109155 Sat, 18 Apr 2015 16:56:59 +0000 http://www.volumesoffun.com/?p=1755#comment-109155 Thanks for sharing this info. What performance gain do you expect? It would be great to have such summary with linear and morton order access fot your project.

]]>