David Williams – Volumes Of Fun http://www.volumesoffun.com Voxel-based games and technology Thu, 20 Aug 2020 20:14:48 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.3 Removing Cubiquity from the Unity Asset Store http://www.volumesoffun.com/removing-cubiquity-from-the-unity-asset-store/ http://www.volumesoffun.com/removing-cubiquity-from-the-unity-asset-store/#respond Sat, 20 May 2017 23:32:07 +0000 http://www.volumesoffun.com/?p=1964 As has been mentioned previously, the current version of Cubiquity is no longer under active development as the focus has shifted to a replacement ‘Cubiquity 2’ system which is being developed outside of the ‘Volumes of Fun’ brand. Although the … Continue reading

The post Removing Cubiquity from the Unity Asset Store appeared first on Volumes Of Fun.

]]>

As has been mentioned previously, the current version of Cubiquity is no longer under active development as the focus has shifted to a replacement ‘Cubiquity 2’ system which is being developed outside of the ‘Volumes of Fun’ brand. Although the replacement system is still a long way from being ready, I feel it is time to remove the current version from the Unity Asset Store.

The reason is that I don’t want to encourage people to use a system which I no longer have the time and resources to support, and I think that having the system available on the asset store does exactly this. Cubiquity for Unity3D was developed under Unity 4 and has only limited testing under Unity 5, and as the Unity 5.x series progresses I’m increasingly becoming aware of problems which I don’t have time to investigate.

The system will remain available on BitBucket as it is open source software, but that provides a slightly higher barrier to entry and comes with a warning about the system no longer being developed. I’m expecting that Cubiquity 2 will go on GitHub to avoid any confusion between the two versions, but more on that in the future.

Share

The post Removing Cubiquity from the Unity Asset Store appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/removing-cubiquity-from-the-unity-asset-store/feed/ 0
Voxeliens is now open source http://www.volumesoffun.com/voxeliens-is-now-open-source/ http://www.volumesoffun.com/voxeliens-is-now-open-source/#comments Mon, 02 Jan 2017 07:58:32 +0000 http://www.volumesoffun.com/?p=1948 Voxeliens is a retro-style arcade shooter and is essentially a 3D voxel-based version of Space Invaders. We released the game in 2012, showed it off at the Develop Conference and have had it accepted for Steam Greenlight. However, as mentioned … Continue reading

The post Voxeliens is now open source appeared first on Volumes Of Fun.

]]>

Voxeliens is a retro-style arcade shooter and is essentially a 3D voxel-based version of Space Invaders. We released the game in 2012, showed it off at the Develop Conference and have had it accepted for Steam Greenlight. However, as mentioned in several previous blog posts, time is no longer on our side and we are re-focusing our efforts on the next version of Cubiquity.

Therefore we have decided to release Voxeliens for free under the MIT license. It now lives on BitBucket alongside PolyVox and Cubiquity (our voxel engines) and prebuilt binaries for Windows are also provided. It should also be possible to built it from source (including on Linux) but this has not been well tested on systems other than our own.

Download from BitBucket

We put a lot of work into Voxeliens so we are pleased to now be able to share it with a much larger audience. Note that we do still have the option of selling it on Steam in the future (the Greenlight campaign remains valid) but it is not clear whether we will due to the setup, testing, and support required. At any rate, we hope you enjoy the game!

Share

The post Voxeliens is now open source appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/voxeliens-is-now-open-source/feed/ 3
Wrapping up PolyVox development to focus on Cubiquity 2 http://www.volumesoffun.com/wrapping-up-polyvox-development-to-focus-on-cubiquity-2/ http://www.volumesoffun.com/wrapping-up-polyvox-development-to-focus-on-cubiquity-2/#comments Thu, 24 Nov 2016 22:25:08 +0000 http://www.volumesoffun.com/?p=1942 I made the first public release of PolyVox nearly 10 years ago on the Ogre 3D forums. At the time it was just a simple demo to show how voxels and Marching Cubes could be used to create more dynamic … Continue reading

The post Wrapping up PolyVox development to focus on Cubiquity 2 appeared first on Volumes Of Fun.

]]>

I made the first public release of PolyVox nearly 10 years ago on the Ogre 3D forums. At the time it was just a simple demo to show how voxels and Marching Cubes could be used to create more dynamic environments, but over the years it evolved into a stand-alone library which has been used by several games and our own Cubiquity voxel engine. It’s been a big part of my life for the last 10 years, but as mentioned in previous blog posts I now have less time and am over-committed with the various projects I’m involved in.

Therefore I have decided to officially cease development on PolyVox, though in practice it has not seen much work for the last couple of years. This follows the wrapping up of the current version of Cubiquity last year, and my plan is still to put the majority of my development time into ‘Cubiquity 2’. This will be completely new voxel engine with more limited scope and a focus on research rather than production use (i.e. for the more adventurous!).

More generally, I have some intention of winding down the rest of ‘Volumes of Fun’ over the coming months and breaking Cubiquity 2 into a standalone organisation and/or project on GitHub. But the details of this aren’t really clear yet, and we also need to work out what to do with Voxeliens. For now the existing support channels (e.g. the forums) will remain open and I expect I’ll just provide email support if/when they disappear.

Share

The post Wrapping up PolyVox development to focus on Cubiquity 2 appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/wrapping-up-polyvox-development-to-focus-on-cubiquity-2/feed/ 1
Cubiquity is now fully open source under the MIT license http://www.volumesoffun.com/cubiquity-is-now-fully-open-source-under-the-mit-license/ http://www.volumesoffun.com/cubiquity-is-now-fully-open-source-under-the-mit-license/#comments Sat, 19 Mar 2016 08:35:15 +0000 http://www.volumesoffun.com/?p=1926 In our last blog post we laid out a new direction for our Cubiquity voxel engine, including open sourcing the code and shifting the focus towards research for a future Cubiquity version 2. The first part of this is now … Continue reading

The post Cubiquity is now fully open source under the MIT license appeared first on Volumes Of Fun.

]]>

In our last blog post we laid out a new direction for our Cubiquity voxel engine, including open sourcing the code and shifting the focus towards research for a future Cubiquity version 2. The first part of this is now complete, and the whole technology stack is now available under the MIT license:

The main advantage (as well as freedom!) of this new MIT release is that users can attempt to compile the core Cubiquity library for new platforms whereas we previously only supported Windows, OS X, and Linux. You’ll be own your own here (there are no real build instructions), but we have had reports of it working at least on the iPhone.

There are a few important points to be aware of for those wanting to work with this code base:

For Unity users: We have not uploaded this MIT-licensed version of Cubiquity for Unity3D to the asset store, basically because we don’t want to go through the building/testing/release process again. The asset store version corresponds exactly to the ver1.2.1 release tag, and only differs from master in terms of the readme and the license (Asset Store free license, rather than MIT).

For Unreal users: Be aware that the Unreal version of Cubiquity is really just a proof-of-concept. We did successfully use it for ‘The Peasants are Revolting‘ but it is not production ready and doesn’t work with the latest version of Unreal Engine. We hope to address this for Cubiquity version 2.

However, please do note that the projects above are now largely inactive. As explained previously, the upcoming Cubiquity version 2 will be a complete rewrite which will build on the lessons which have been learned while creating the existing system. Development will take place in a new repository once we have something to show, though at the moment it is very much in the research and prototyping stage.

Share

The post Cubiquity is now fully open source under the MIT license appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/cubiquity-is-now-fully-open-source-under-the-mit-license/feed/ 7
Reflections on Cubiquity and finding the path forward http://www.volumesoffun.com/reflections-on-cubiquity-and-finding-the-path-forward/ http://www.volumesoffun.com/reflections-on-cubiquity-and-finding-the-path-forward/#comments Fri, 23 Oct 2015 21:37:33 +0000 http://www.volumesoffun.com/?p=1904 —– > Update: Cubiquity 2 is now on GitHub here. <—– When we began working on Cubiquity the main idea was to expose our PolyVox library through a higher-level interface and tools. PolyVox is powerful and flexible, but requires a … Continue reading

The post Reflections on Cubiquity and finding the path forward appeared first on Volumes Of Fun.

]]>

—– > Update: Cubiquity 2 is now on GitHub here. <—–


When we began working on Cubiquity the main idea was to expose our PolyVox library through a higher-level interface and tools. PolyVox is powerful and flexible, but requires a strong knowledge of C++, templates and computer graphics to use effectively. By wrapping this in Cubiquity and integrating it with Unity/Unreal we were hoping to bring (some of) it’s capabilities to a larger audience.

The project has been a reasonable success, with a lot of interest from the Unity and Unreal communities and even a game launched on Steam using the technology. However, it is also clear that the original vision is simply too large to finish as a personal side project, especially with diminishing amounts of free time and a desire to adjust my work/life balance. This led to use recently releasing the system for free, but further steps need to be taken to actually reduce the scope.

In this blog post I want to outline the areas in which I/we will be cutting back on development, and explain how it will affect existing users. I also want to define a direction for a future ‘Cubiquity 2.0’ such that it is both smaller and also more technically interesting to work on. This means shifting the focus to research rather than delivering a drop-in system, open-sourcing the complete technology stack, and reducing (but not eliminating) the level of integration provided for Unity and Unreal.

Open sourcing the core Cubiquity library

The proposed change of direction is likely to cause some concerns for users who are already working with Cubiquity, and so I hope to partially alleviate these by announcing that we will release the core Cubiquity library as open source. This is also expected to reduce our workload in the following ways:

  • End users will become responsible for building and testing the library on the platforms which they wish to support. On the plus side, they may also be able to port the library to new platforms (Android, iOS) which we did not have time for.
  • We may remove Cubiquity from the Unity Asset Store and handle distribution only through BitBucket and/or Github. A more developer-focused Cubiquity may not be a good fit for the Asset Store where users expect drop-in solutions.

This applies to both the current version of Cubiquity (which may not see much further development) and also to a future ‘Cubiquity 2.0’ code base (which will likely be a complete rewrite).

Shifting the focus back to research

When we first released PolyVox back in 2006 the idea of using voxels to represent worlds in games was fairly novel. There was some interesting work by the likes of Ken Silverman and Sven Forstman but voxel techniques were not widely used [1]. The arrival of Minecraft changed all of that, and overnight voxels became the new ‘hot thing’.

Fast-forward ten years and it now feels like everyone is developing a voxel engine, and the techniques used within PolyVox and Cubiquity are no longer particularly novel. But there is a lot of interesting research to be done as shown by projects like Atomontage and VoxelQuest, and I’ve actually been working on an interesting prototype of a new (to my knowledge) voxel-rendering algorithm.

I’ll talk more about my ideas in the a future post, but the important point for now is that the difference between implementing new algorithms vs. really making them production ready is at least an order of magnitude. I therefore expect future versions of Cubiquity to be a little more experimental, a little more developer-focused (rather than artist-friendly), and less like the drop-in solution we currently provide on the Unity asset store.

Reducing the scope

I also have some concrete plans to cut a couple of significant features from Cubiquity. However, note that these changes will not directly affect the current codebase. Instead, Cubiquity 2.0 will most likely be a complete rewrite and will be designed without them in place.

No more Marching Cubes terrain

Cubiquity currently provides both colored-cubes style voxels and smooth (Marching Cubes) terrain. This was made possible because PolyVox supports user defined voxel types and custom surface extractors, but the two voxel systems still require different shaders and editing tools. Developing both systems in parallel is proving to be a rather large task.

We will therefore drop the Marching Cubes terrain and focus entirely on simple colored voxels, with the intention of making them as small as possible. Atomontage has shown that sufficiently small voxels can produce attractive terrains while also modeling buildings and objects, so I hope that a dedicated terrain renderer will not be needed. It is the generality of such a system which makes it interesting, as well as the ability to convert any existing dataset to this format.

Moving editing tools from Unity/Unreal to a separate application

Cubiquity for Unity allows the users to sculpt and paint terrains inside the Unity editor, and there is also basic support for editing the colored cubes volumes. Cubiquity for Unreal offers some similar features though they are not currently as complete. Overall this requires a lot of duplication of code and effort.

The plan for future versions of Cubiquity is to instead have a separate application which can be used for creating, importing and (possibly) editing volumes, and to turn the Unity and Unreal integration layers into much something much thinner. If users wanted to create in-game editors this could still be achieved via the Cubiquity API, as is the case at the moment.

Reduced focus on the Unity integration

We began working on Cubiquity around 2012, and at the time Unity was taking the indie game development world by storm. It was providing a cheap yet powerful platform and was being used by a huge number of indie games. As we were aiming to sell Cubiquity it made sense to provide an integration layer with Unity. However, from a technical standpoint it was quite a poor fit for a few (related) reasons:

C# .vs C++: Cubiquity is written in C++ but Unity scripts are written in C# (or sometimes a variant of JavaScript). This means we had to write a C interface around Cubiquity and then call that via C#’s P/Invoke magic from Unity.

No plugin support on Unity Free: Plugin support was a Pro-only feature on Unity 4, so we had to resort to some tricks and hacks to get Cubiquity loading properly. This feature is now free in Unity 5 but we haven’t had time to update our scripts to take advantage of it.

Need to compile libraries: Because Cubiquity was provided as a native-code library we have to compile it for every platform we wish to support. So far we have only supported Windows, Linux and OS X, but with both 32 and 64 bit versions that’s already six libraries to build and test.

Platform support: For the reasons outlined above, it has not been practical for us to support all platforms. Mobile has so far been too much work, and webplayer is simply not possible due to the use of native code. This causes some frustration for users who build their game and then find they cannot export to the platform of their choice.

Some of these problems disappear with Unity 5 and our move towards open source, but we are stuck with the C# vs. C++ issue and the need to compile separately for each platform (though we now defer that problem to the user). By contrast, integration with Unreal should be much more straight-forward, and has mostly been held up by lack of time/resources (see below). In this case we would simply be able to drop our Cubiquity C++ files into an Unreal project.

I’m honestly not sure where I’m going with this. Unity is still a massively popular game development platform, and from what I’ve seen it is probably easier to get into than Unreal. I do expect we will still provide some degree of support for it, but with higher technical requirements on the user and less in the way of Unity-specific examples, documentation, builds, etc. But really we’ll just have to see how the next version of Cubiquity develops, and how well the algorithms match with the architecture of Unity.

Increased focus on the Unreal integration (long term)

Our recent work on ‘The Peasants are Revolting‘ was my first exposure to the new Unreal engine, and I was very impressed. Actually my interest in the engine goes back to the original Unreal which really piqued my interest in game development. However, it was only the arrival of UE4 that the engine became accessible to indies, and by this time I had a good couple of years invested into the Unity integration.

The Cubiquity for Unreal integration was therefore handled exclusively by Matt, who has done an amazing job considering the constraints he was under. But (like me) he has a number of real-life commitments, and the task was made more difficult by Cubiquity being closed source. Furthermore, the motivation for integrating Cubiquity with Unreal is not as clear as for the Unity version, because users have the option of just using PolyVox directly (which offers more flexibility and full source access).

Things look brighter in the future though, as Cubiquity will become open source and so the relevant files can simply be dropped into the project. Also, the core technology behind Cubiquity will (probably) be quite different from PolyVox and so they won’t be competing over the same space. I hope to spend some time in the future either assisting Matt or taking over some aspects myself (depending what he wants), but this won’t happen until the core technology is developed.

Conclusion

This has been a difficult post to write because it so drastically changes the direction of a project which has had a lot of time sunk into it. However, it does seem like the right decision to ensure we stay motivated and work towards something achievable, but exactly what that is remains to be seen.

[1] 90’s-style ‘voxel’ terrain as used in Commanche, Delta Force, etc doesn’t count here as it was not really volumetric (no caves, overhangs, etc). It was just raycasting a heightfield, and as far as I can tell the term ‘voxel’ was just used as a marketing gimmick. If anyone has evidence to the contrary then do let me know!

Share

The post Reflections on Cubiquity and finding the path forward appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/reflections-on-cubiquity-and-finding-the-path-forward/feed/ 17
Cubiquity for Unity3D is now free! http://www.volumesoffun.com/cubiquity-for-unity3d-is-now-free/ http://www.volumesoffun.com/cubiquity-for-unity3d-is-now-free/#comments Tue, 09 Jun 2015 21:36:16 +0000 http://www.volumesoffun.com/?p=1800 Well we’ve got some exciting news today – we’re pleased to announce that Cubiquity for Unity3D is now available for free! It has always been free for non-commercial and evaluation use, but we are removing this restriction so that you … Continue reading

The post Cubiquity for Unity3D is now free! appeared first on Volumes Of Fun.

]]>

Well we’ve got some exciting news today – we’re pleased to announce that Cubiquity for Unity3D is now available for free! It has always been free for non-commercial and evaluation use, but we are removing this restriction so that you can use the system for commercial purposes too. This is effective immediately, and you can download Cubiquity for Unity3D via the asset store or from BitBucket.

Cubiquity let's you create natural voxel terrains and edit them in real time, or build your worlds from millions of tiny colored cubes.

Cubiquity let’s you create natural voxel terrains and edit them in real time, or build your worlds from millions of tiny colored cubes.

So what has led to this decision? Well, there are a number of factors at play here:

Time restrictions: Over the last year we have spent a lot of time developing Cubiquity for Unity, but I anticipate time being less plentiful in the future. I’ve just accepted a new job as a senior software engineer, expect to be moving house in the coming year, and we have also had Voxeliens be accepted onto Steam. With less time available for development and support I don’t feel comfortable charging money for the system.

Research aims: There is a huge difference between a research-oriented project and a commercial one. Selling Cubiquity for Unity3D means a lot of work has to go into the workflow, documentation, support, and other tasks which are frankly not much fun. I’d rather shift the focus and spend more time developing cool features and demos, or doing more general voxel research.

Increase number of users: Getting paid for developing Cubiquity for Unity3D definitely has it advantages, but I can honestly say that the satisfaction of seeing someone else use your system is far more rewarding. We really hope that going free can further increase adoption and that we’ll see more games building on Cubiquity.

So what’s the catch?

There isn’t really a catch, but users should be aware that the core Cubiquity library remains closed source. A precompiled version of this Cubiquity library is shipped with Cubiquity for Unity3D and you can use this mostly as you please (see asset store terms and conditions) but you don’t have the source code to build it yourself. You do however have the C# scripts and shader code which integrate this library with Unity.

We do still have further opportunities to generate revenue from Cubiquity by charging for source code licenses, charging for additional platforms (e.g. mobile), or offering contract services. I don’t yet know if we’ll pursue any of these but there are no short-term plans to do so.

What about Unreal Engine 4 (UE4)?

In principle none of the above should affect Cubiquity for UE4. Matt is still working on this though again he is limited to his spare time. The pricing and distribution model for Cubiquity for UE4 may or may not match the Unity version – we simply haven’t decided this yet.

Support

All support for Cubiquity for Unity3D will be handled through our existing thread on the Unity forums. There is also a board on our own Volumes of Fun forum, but we encourage users to use the Unity thread where possible as it boosts the visibility of the system and shows an active community. Please avoid sending email or private messages unless the content really needs to be private, as we try to keep communication open where possible.

Anyway, we hope you enjoy playing with Cubiquity for Unity3D and look forward to seeing what you create!

Share

The post Cubiquity for Unity3D is now free! appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/cubiquity-for-unity3d-is-now-free/feed/ 6
Implementing Morton ordering for chunked voxel data http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/ http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/#comments Fri, 17 Apr 2015 21:20:18 +0000 http://www.volumesoffun.com/?p=1755 We’ve recently been doing some work in PolyVox to switch the ordering of voxel data from linear order to Morton order. This work is now complete, and in this relatively technical post I’m going to highlight a couple of the … Continue reading

The post Implementing Morton ordering for chunked voxel data appeared first on Volumes Of Fun.

]]>

We’ve recently been doing some work in PolyVox to switch the ordering of voxel data from linear order to Morton order. This work is now complete, and in this relatively technical post I’m going to highlight a couple of the interesting tricks which we came across while doing it. Hopefully these will be beneficial to other people working on the low-level details of voxel engines.

Like many voxel engines, PolyVox allows volume data to be broken down into a number of ‘chunks’. The primary advantage of this approach is that not all the data has to be loaded into memory at the same time, and we can instead load and unload chunks on demand. Note that this is an implementation detail of the our ‘PagedVolume’ class, and algorithms which operate on the data (mesh extractors, raycasting, etc) are not aware that the data is stored in this way.

The size of each chunk can be specified by the user (with the ideal size depending on a number of factors) but typically contain 32³, 64³, or 128³ voxels. The ‘ordering’ of these voxels refers to the way they are laid out in memory, and two possibilities are shown below for the 2D case. The linear ordering is the easiest to understand and can be traversed with a simple nested for loop, but the Morton ordering brings numerous benefits in terms of locality of reference, ease of downsampling, and increased compressibility.

Linear ordering (left) vs. Morton ordering (right)

Linear ordering (left) vs. Morton ordering (right)

However, the purpose of this blog post is not to explain the benefits of Morton ordering, nor to describe how (x,y,z) positions are mapped to locations on the Morton curve. For this we refer you to the Wikipedia article and the excellent blog posts by Jeroen Baert and Fabian Giesen. Instead, we wish to highlight a couple of optimizations which were useful in our implementation.

Morton index calculation

Jeroen Baert did some extensive tests on the most performant way to determine Morton curve positions from a 3D input position. The conclusion was that it is fastest to make use of a lookup table rather than perform a series of bitwise operations – a perhaps surprising result given the relative cost of processor cycles vs. memory access on modern hardware.

We tested both approaches and were able to verify Jeroen’s original findings. Compared to using a simple linear index for the 3D position, computing and accessing a Morton index took roughly four times as long. By comparison, using the lookup table only took about 40% longer than the linear index, clearly showing the benefits of this approach. None-the-less, a 40% increase in voxel access time is a significant price to pay even given the other advantages of the Morton ordering, and it is here that we make our first useful observation.

Jeroen is working in the context of SVO rendering and is using very large volumes. His function to map a 3D position to on the Morton curve looks as follows:

inline uint64_t mortonEncode_LUT(unsigned int x, unsigned int y, unsigned int z)
{
    uint64_t answer = 0;
    answer =    morton256_z[(z >> 16) & 0xFF ] | // we start by shifting the third byte, since we only look at the first 21 bits
                morton256_y[(y >> 16) & 0xFF ] |
                morton256_x[(x >> 16) & 0xFF ];
    answer = answer << 48 | morton256_z[(z >> 8) & 0xFF ] | // shifting second byte
                morton256_y[(y >> 8) & 0xFF ] |
                morton256_x[(x >> 8) & 0xFF ];
    answer = answer << 24 |
                morton256_z[(z) & 0xFF ] | // first byte
                morton256_y[(y) & 0xFF ] |
                morton256_x[(x) & 0xFF ];
    return answer;
}

The variables ‘morton256_x’, ‘morton256_y’, and ‘morton256_z’ are the lookup tables, and each stores 256 entries (enough to perform the mapping for a single byte) due to the impracticality of having an entry in the lookup table for every possible value of the unsigned int inputs. Construction of the full Morton key is therefore done by using these lookup tables repeatedly to process each byte of the input, and them combining them with more bitwise operations.

For our purposes the size of each chunk is actually very limited, and setting a hard limit of 256^3 seems reasonable. The actual volume can of course be much larger, consisting of many of these chunks. Therefore we apply this hard limit and reduce the above code to just three lookups which are OR’d:

template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Chunk::getVoxel(uint32_t uXPos, uint32_t uYPos, uint32_t uZPos) const
{
    uint32_t index = morton256_x[uXPos] | morton256_y[uYPos] | morton256_z[uZPos];
    return m_tData[index];
}

With this change the calculation of the position on the Morton curve is about 1-2% faster than with the linear version, though with such a small improvement it is hard to be sure. At least, we are not paying any extra access cost for the benefits which Morton ordering provides.

Fast neighbourhood access

As well as ensuring that random access to any voxel is as fast as possible, it is also important to consider realistic access patterns. In the context of voxel engines this typically means providing fast access to a given voxel’s neighbours as this is often required for tasks such as filtering, normal estimation, and surface extraction.

Access to such neighbours is trivial with a simple linear ordering. For a given position (x,y,z), if we want to access position (x+1,y,z) then we know it is simply the next voxel in memory. There is no need to work out which chunk it is in (disregarding edge cases here) nor to perform the index calculations. In PolyVox we provide ‘peek…()’ functions to retrieve a neighbour of our current voxel, and so an older (linear) version of PolyVox peeked one voxel in the x direction as follows:

template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
{
    if(CAN_GO_POS_X(this->mXPosInVolume) )
    {
        return *(mCurrentVoxel + 1);
    }
    return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume);
}

Note that the ‘CAN_GO_POS_X’ macro was just to ensure we were not on a chunk boundary, because if we were then our clever trick didn’t apply and we fell back on a regular call to getVoxel(). Peeking in multiple directions was more complex but the same principle applied:

template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
{
    if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
    {
        return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
    }
    return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
}

However, the situation becomes more complex when Morton ordering is applied. In this case, the neighbouring voxel in the x direction is not simply next to the current voxel in memory, and things get even harder when peeking in multiple directions at once. We did not find much information on how to handle this correctly, which is why we decided to present our solution here.

The naive approach is to take the Morton position for our current voxel and reverse the encoding process to obtain the original (x,y,z) position. This can then be modified by adding or subtracting the desired offset to the desired component(s), and the resulting 3D position can then be re-encoded into an index on the Morton curve. Clearly this involves quite a lot of processing.

It is possible to directly combine (‘add’?) two Morton positions as alluded to by this StackOverflow answer. However, this is still relatively expensive and again requires some significant bit-shifting. Update: Fabian Giesen has a much more detailed coverage (and more efficient version) of this approach – see the comments and also Texture tiling and swizzling.

At this point Matt made a useful observation. As he states there, “for a given (x,y,z) which has a Morton position p; if we want to peek at (x+1,y,z) then the amount by which p must increase, Δp, is dependent only on x and is independent of y and z. This same logic holds for peeking in y and z”. In other words, we can make use of three more lookup tables (for x, y, and z) which store the offset for moving a single voxel in each direction.

Such lookup tables can be generated by a simple program such as this (based on this code) which computes the offset between different pairs of adjacent x, y and z positions. The size of the lookup table needs to be at least as large as the largest chunk size we wish to support, though smaller chunk sizes are also supported by this as the elements of a smaller table are a subset of the elements of the large table.

In PolyVox we are making use of three 256 element tables allowing us to support chunks of up to 256^3 voxels. The table for moving/peeking one voxel in the x direction is:

static const std::array&lt;int32_t, 256&gt; deltaX =
{
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 28087,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 224695,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 28087,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 1797559,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 28087,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 224695,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 28087,
    1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1, 3511, 1, 7, 1, 55, 1, 7, 1, 439, 1, 7, 1, 55, 1, 7, 1
};

and you can find the other tables in the PolyVox source here. We also define a few macros to make using the tables easier:

...
#define POS_X_DELTA (deltaX[this->m_uXPosInChunk])
...

With this is place, the Morton version of our function for peeking one voxel in the x direction becomes as simple as:

template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
{
    if (CAN_GO_POS_X(this->m_uXPosInChunk))
    {
        return *(mCurrentVoxel + POS_X_DELTA);
    }
    return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume);
}

and for peeking multiple directions at once:

template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
{
    if (CAN_GO_POS_X(this->m_uXPosInChunk) && CAN_GO_POS_Y(this->m_uYPosInChunk) && CAN_GO_POS_Z(this->m_uZPosInChunk))
    {
        return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA + POS_Z_DELTA);
    }
    return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
}

Conclusion

We have found that Morton ordering works well for storing voxel data in chunks inside PolyVox. While we can’t be sure that computing a Morton position is quite as fast as computing a linear position, we can say that the improved memory access time at least makes up for this due to the improved cache locality. Benefits such as improved compression and easier downsampling are then essentially free.

If you are interested in any of our work above then you can check out the PolyVox code in BitBucket (currently you need the develop branch) and look at the PagedVolume*.h/inl files. If you want to see the discussion and tests which led to the conclusions above then you can have a read of our thread in the issue tracker.

In the future we intend to have a few more of these posts covering the low-level details of PolyVox and Cubiquity, so stay tuned!

Share

The post Implementing Morton ordering for chunked voxel data appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/implementing-morton-ordering-for-chunked-voxel-data/feed/ 12
A new version of Cubiquity for Unity3D is now available http://www.volumesoffun.com/new-version-cubiquity-unity3d-now-available/ http://www.volumesoffun.com/new-version-cubiquity-unity3d-now-available/#comments Wed, 04 Feb 2015 12:44:15 +0000 http://www.volumesoffun.com/?p=1719 Today we are pleased to announce that a new version of Cubiquity for Unity3D has been released on the asset store. Version 1.2 brings performance and memory gains, adds support for 64-bit architectures, includes faster transfer of mesh data from the … Continue reading

The post A new version of Cubiquity for Unity3D is now available appeared first on Volumes Of Fun.

]]>

Today we are pleased to announce that a new version of Cubiquity for Unity3D has been released on the asset store. Version 1.2 brings performance and memory gains, adds support for 64-bit architectures, includes faster transfer of mesh data from the native library, and provides experimental heightmap import.

A new example map is included (imported from here).

Our new example map shows a city modeled at a resolution of 512x512x64 voxels which can be destroyed in real-time (complete with physics). Data courtesy of William Rigby and the game ‘Build&Shoot’).

We have improved both performance and memory usage by introducing an octree to reduce the number of mesh chunks which are active at an given time. We’ve combined this with a sophisticated time-stamping system, which allows us to minimize the amount of work required to synchronize our internal representation with Unity’s scene hierarchy. The city map shown above loads in just a few seconds and runs smoothly with destruction and physics enabled.

We have also replaced our ‘ConvertToVDB’ and ‘ConvertToImages’ tools with a single general purpose tool called ‘ProcessVDB’. This provides experimental support for importing heightmaps as terrain volumes – experimental in the sense that it seems to work well but needs some refinements to the workflow.

This map was created using the new (experimental) functionality to import from a heightmap.  It can then be edited as usual to create caves and overhangs.

This map was created using the new functionality to import from a heightmap. Once in the editor the usual sculpting tools can be applied to create caves and overhangs, or to apply materials and textures.

The licensing model hasn’t changed – you can use the system free for non-commercial and evaluation use, or for $200 (per-seat) you can buy a commercial license through the Unity asset store:

For those of you who are waiting on the integration with Unreal Engine 4, I spent some time with Matt over Christmas and saw that the system is indeed progressing nicely. Both the smooth terrain and ‘colored cubes’ volumes are largely working though integrating with the editor and blueprint system is a lot of work. We both have only limited time so there’s not currently a set schedule for the initial release, but keep an eye on the forum thread for the latest updates.

Share

The post A new version of Cubiquity for Unity3D is now available appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/new-version-cubiquity-unity3d-now-available/feed/ 3
A new version of Cubiquity for Unity3D has been released http://www.volumesoffun.com/new-version-cubiquity-unity3d-released/ http://www.volumesoffun.com/new-version-cubiquity-unity3d-released/#comments Fri, 15 Aug 2014 19:22:43 +0000 http://www.volumesoffun.com/?p=1682 It’s been a quiet few months, but we’re happy to say that a new version of Cubiquity has just landed on the asset store. Version 1.1.3 is primarily a bug-fix release but also adds a few new features such as … Continue reading

The post A new version of Cubiquity for Unity3D has been released appeared first on Volumes Of Fun.

]]>

It’s been a quiet few months, but we’re happy to say that a new version of Cubiquity has just landed on the asset store. Version 1.1.3 is primarily a bug-fix release but also adds a few new features such as normal mapping of the colored cubes volumes and an example showing how to build and save voxel databases from Unity scripts.

Colored cubes can now have custom diffuse and normal maps applied. Shiny!

We’ve also tidied up a lot of stuff internally, for example all of our PolyVox enhancements have been merged back into the main develop branch and we have overhauled the Cubiquity build system. Perhaps not so exciting for end users but still an important step as development can move a bit more smoothly from here on.

Licensing is the same deal as before – you can use the system free for non-commercial and evaluation use, or for $200 you can buy a commercial license through the Unity asset store:

Looking forwards, the main request has been for larger volume support and better performance with less memory. In other words, we’re going to put some work into optimization and possibly providing some tools (importers, etc.) to help create the larger environments.

We’ll try not to go another three months without posting, and I think the upcoming changes should give us plenty to show off!

Update 3rd Sept 2014: Version 1.1.3 is now out with collision and physics fixes for smooth terrain. The links above have been updated.

Share

The post A new version of Cubiquity for Unity3D has been released appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/new-version-cubiquity-unity3d-released/feed/ 9
Cubiquity for Unity3D is now on the Asset Store! http://www.volumesoffun.com/cubiquity-unity3d-now-asset-store/ http://www.volumesoffun.com/cubiquity-unity3d-now-asset-store/#respond Sat, 10 May 2014 07:36:46 +0000 http://www.volumesoffun.com/?p=1672 Hi all, I’m pleased to announce that we’ve just made the first official release of Cubiquity for Unity3D, and that it’s now available to purchase from the asset store. This is a huge milestone for us and comes just over … Continue reading

The post Cubiquity for Unity3D is now on the Asset Store! appeared first on Volumes Of Fun.

]]>

Hi all, I’m pleased to announce that we’ve just made the first official release of Cubiquity for Unity3D, and that it’s now available to purchase from the asset store. This is a huge milestone for us and comes just over a year after we first showed our work on Unity3D integration.

The asset has been released at the $200 price point which we’ve been throwing around for a while now, and it remains free for non-commercial and evaluation use. Anyone who has been following our regular snapshots will already have a good idea what the system does, but the uninitiated can get the latest free version below:

It’s also worth mentioning that we’ve updated the documentation and placed it online. You can read it here:

And as mentioned previously, if you like the system you can now buy the commercial version at the asset store:

This is really just the start of the journey for Cubiquity and we have plenty of ideas for how we want to further develop the system over the coming months. But that can wait for a future post – for now we’d just like to thank everyone who has spent time testing our system, giving feedback, and providing encouragement. You’ve helped get Cubiquity for Unity3D to where it is today!

Share

The post Cubiquity for Unity3D is now on the Asset Store! appeared first on Volumes Of Fun.

]]>
http://www.volumesoffun.com/cubiquity-unity3d-now-asset-store/feed/ 0