You can get Voxel Farm now. For more information click here.

Monday, February 18, 2013

Unity makes strength

I like writing everything from scratch, but not everyone shares this form of dementia.

Many in the past have asked whether any of this would run on mainstream game engines. I could not see a reason why not. The VoxelFarm engine outputs traditional polygons, in theory it could be plugged into any engine using polygons for rendering, physics, etc. That remained a nice theory until recently. Now we have some hard proof:


This screnshot shows the VoxelFarm realtime engine providing polygons for terrain in Unity.

Here is are a video. It shows a simple physics test and a little bit of walking. The capture speed and resolution is not good, but hopefully you will get the idea.


I understand if this tech is to be widely used, it will likely come in the form of plugins for mainstream engines. So think this is very encouraging news.

32 comments:

  1. Ohhh nice!
    Many engines, including Unity, use single precision floating point values for physics and location. If you walk 2-5km from the origin point in Unity you should find that physics starts to become unstable as the floating point precision looses resolution.
    As you might imagine its a fairly big limitation for a project such as yours.

    That said, you should still go ahead with Unity integration 100%! It'll be an awesome tech demo in a massive audience and it'll be a good exercise in integration for yourself as Unity's plugin framework is actually kind of nice.

    ReplyDelete
    Replies
    1. I use floats too. I keep a frame of reference in doubles for the absolute stuff, but mostly everything you see in a scene is based on differentials to this frame, so the magnitudes are always manageable as floats.

      Delete
    2. Are you able to expand upon that a little more? I've been thinking about ways to get around the SP float point issue and haven't yet come up with an elegant solution.
      When a player walks to the edge of a 'frame' is he reset back to origin in a new frame?

      Delete
    3. Well, it is only a few things that are affected by large viewer coordinates. It is a smaller problem that what you may think, at least in my case.

      For instance the actual geometry can run in floats, since everything is generated in a clipmap around the viewer. Clipmap cells can be transformed using floats because their position is always relative to the origin of the clipmap. Floats are enough to cover a dozen kilometers into the horizon.

      The problem I encountered was with patterns that used global coordinates, for instance texture coordinates for triplanar mapping. You cannot just use a differential to the camera cause the textures would "swim" over the geometry as you move. So I establish this frame of reference only once per session and use it for the texture coordinates along the session.

      The viewer would need to walk for hundreds of kilometers before any noticeable errors would begin to show up. At normal walking speeds this would mean walking straight for days without ever closing the program. While it is possible, it is a very unlikely scenario.

      And yes, if you see the current position is too farm from the original reference, you can always do a reference frame update. It will make the texturing change and certainly it will look weird, but it will only happen once in a blue moon.

      Delete
  2. you are the king of voxels

    ReplyDelete
  3. Hell yeah! That's a nice milestone, Miguel! You keep amazing me with the work you put into this, and it's been a real pleasure following this blog for the past years :) Keep up the good work!

    ReplyDelete
  4. This is really great. I was going to ask about this. All I really care about is game-play programming. Being able to generate interesting landscapes with structures would allow me to spend time on combat instead of map-making. I would pay many dollars for this.

    ReplyDelete
  5. This is looking really nice. I'm a unity developer myself, and it's super impressive seeing your system running in it. I was also under the impression that most of the stuff you were doing would be accessible only through your own engine - obviously I was wrong!
    I am curious to see more developments in this area if you continue it. It looks like you've still a ways to go on a full Unity implementation, I saw some seams in the geometry and there weren't materials applied (which makes sense since you wouldn't be able to port your rendering engine over).
    I think the nice thing about Unity is that it's really easy to craft gameplay. Do you think as you start to move towards a game design for your procedural world that you'll start using tools like Unity, or will you stick to crafting the gameplay in your own engine?

    ReplyDelete
    Replies
    1. Yes, there are many things to fix and cover. The tricky part was to create a channel between the generation in voxelfarm and the Unity pipeline and have it perform nicely.

      Materials are coming, and they will be as rich as the ones shown in the standalone demo. We will be feeding the albedo and normals to Unity per fragment, so the material data will come from voxelfarm, but the actual rendering will be done by Unity.

      As an engine my goal is not to cover physics, AI, or anything else beyond the procedural generation of content. I would always rely on a host engine like Unity for the gameplay stuff.

      Delete
  6. Very happy to see an initial version of this running inside Unity! Can't wait to see the further progress...

    ReplyDelete
    Replies
    1. Thanks Rune. It was you who started this idea so you deserve credit. Also thanks for answering all my newbie questions.

      Delete
  7. It looks so... different without the textures XD, just goes to show how important a bunch of good textures is!

    ReplyDelete
  8. Wow! This tech in KSP would melt my brain! Imagine how much more interesting exploring far away worlds would be with some of this awesome terrain generation.

    ReplyDelete
    Replies
    1. You mean Kerbal Space Program? (Try not to use acronyms in places where they might not be recognised by everyone =3)

      Delete
    2. YES! having just bought Kerbal Space Program the other day, i think this would be amazing! maybe if we all donated some funds to fly miguel to mexico to meet the squad/KSP developers, they could hammer out a deal while listening to tijuanan jazz, drinking tequila, and discussing code ;D

      slightly more seriously tho, are there any compromises you have to make when importing/converting your voxel-farm engine into unity? or is it just a matter of ensuring that unity can communicate with the voxel engine effectively? (not sure how i would ask this question in more technical terms :S ) at any rate, small design modules utilizing the various aspects of your work (ie, political/border generation, terrain & elevation, building placement, etc.) could be sold individually, and could potentially bankroll your ongoing dev work in style! :)

      Delete
    3. Well there is one huge compromise, this runs only on PCs as the Unity plugin uses a C++ DLL.

      Besides this, not many compromises at this point. Unity has some sort of lowest common denominator syndrome in some aspects, that is a concern moving forward. A concrete example: In the standalone renderer I use texture arrays, which is a nice way to batch complex looking objects into a single draw command. Unity does not support them at the moment, so a different way to pack textures must be used, atlases for instance. This brings a new set of problems the arrays already solve. It may lead to lower quality overall.

      Delete
    4. So, does this mean you might change to Unity, or will you continue developing your own stuff?

      Delete
  9. Man, I am super excited by this. It really opens up a lot of doors, I can't wait to see what people do with it!

    ReplyDelete
  10. Awesome! If you get all the kinks worked out and get this put on the Unity asset store, this could be mind-blowingly huge.

    ReplyDelete
  11. I was thinking on doing a voxel terrain generator for a game I am working on, on compute shaders inside unity, as unity suports them now. But you made me think twice about it. I wonder if it is better do it on openCL or compute shaders.

    ReplyDelete
  12. Looks great! I Could definitely be dropping some cash for this! ESPECIALLY like seeing it run in Unity!

    ReplyDelete
  13. Great work on getting this in Unity! I am also building a semi-procedural world system (none-code-based) for unity, but if you manage to get the entirety of your system into unity it would probably blow mine away :P, now I have to work even harder XD...

    ReplyDelete
  14. This is absolutely amazing work! Breath taking scale, scope, and detail. Keep up the good work!

    ReplyDelete
  15. Awesome. This is very inspiring.

    ReplyDelete
  16. I'm really looking forward to seeing where this goes

    ReplyDelete
  17. Hello Miguel,

    Little bit different of a Unity + VoxelFarm question, but do you think it would be possible to "code" your engine 100% in Unity? That means to not have a plugin and basically be all C Sharp... I'm curious because of how Unity (or plenty of other engines) is able to deploy to so many platforms and that as it gets updated and developed a lot, you may not have future problems when newer, more powerful versions come out (or maybe just less problems).

    I know you won't ever be doing this, but in theory do you think that it is possible, or would it just run far too slow from Unity's limitations?

    ReplyDelete
    Replies
    1. Yes, it can all be written in C#. I'm not sure what would be the performance hit however.

      Delete
    2. Thank you for your hasty reply!

      Would you happen to have an estimate on the performance hit? (Or just some educated guess). I'm curious if your 14 millisecond trees would suddenly take 500 milliseconds.

      And while I'm here: Keep up the great work and make sure you make it big. In 10 years I expect to see a Wikipedia page in your name with a Bio and your Voxel accomplishments. Cheers!

      Delete
    3. No idea what the performance hit will be. This kind of things you really have to measure.

      Delete
    4. Alright, no problem!

      Maybe I'll try as I'm very interested in it. It sounds like a great hobby.

      Again, thanks. Perhaps I'll post again if I get anywhere in my attempts.
      Cheers,
      Rob.

      Delete
  18. "I like writing everything from scratch, but not everyone shares this form of dementia." = story of my life :D

    ReplyDelete

There was an error in this gadget