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

Sunday, September 23, 2012

Voxels in the wind

Fall is here and it is getting windy. It is a good time to finally add some animation to grass blades and tree branches.

 Here you can see some results:


There is nothing fancy going on here. The post title is deceiving since no voxels were animated, just traditional polygonal billboards. The motion is a few sine waves overlapping at different frequencies. The next step is to feed wind vectors to the vertex shader. This will create turbulence near cliffs and some other nice effects.

And then some leaves and other particles flying around for increased realism.


  1. That. Looks. Amazing!

    You've got quite apparent LoD transitions there in the second video. Is this intentional to keep FPS down?

    I'd love to see some real-time shading under those trees. Will give the grass more depth and the forest more mood.

    Moving clouds shadows on the ground also provide a really surprising amount of realism to a scene too I've found.

    1. There is a reason behind the noticeable LOD transitions. I will cover that in the future.

      As you say, proper lighting will improve the scene a lot.

  2. There's too much back and forth movement in the grass, I feel. With enough wind to make the grass move that much, it wouldn't normally "bounce back" so far, it would be mostly leaning over in one direction and bouncing slightly there. But just lowering the amount of movement in the grass relative to the trees would probably work fine.

    It just occurred to me that perhaps why my brain is saying "that grass is moving too much" is that in a real forest like that a lot of the wind would be obstructed by trees and wouldn't get through to the grass. So while treetops might be moving a lot, grass may be barely swaying.

    At the end there, it felt like you were a giant striding among the forests of your kingdom. Can't imagine what one would do in a game like that, though, except stride around.

    As usual, simply beautiful work! :D

    1. I agree with you that the movement is not right, especially for the grass. Still working on it...

  3. ... Okay... that was my few minutes of complete silence in awe...
    I especially loved the grass, even though at times it almost made me sea-sick XD.

    The biggest problem there atm, is indeed the quality changes as you approach, it is too obvious and should be more subtle.
    As for the wind thingy, will it actually replace the sine-waves, or just add to it?

    Furthermore, Now, or soon, would be a good time to build a world, and allow us to walk around in it =3. I think I could spend probably a good half an hour to an hour just walking through plains like that, with the wavy grass.
    Oh, that reminds me, normally there isnt as much grass under trees, is there? Only in the spots where the light comes through the canopies.

    1. The quality changes are due to LOD transitions happening too close to the viewer. There is a good reason for this, but it is not yet the time to talk about it.

    2. I do hope you will be able to improve it so it seems less abrupt though, since its really quite a gut punch saying ''Hey! You are in a virtual world, none of this is real!'' Which is unfortunate =/.
      Looking forward to hearing the reason though =D, my bet is that it has something to do with the online streaming =3.

    3. Even nearby LOD transitions can be ok if they maintain geometry a bit more and are more just texture transitions one or two steps out.

      A tree that one second looks like it's trunk is wider on top abruptly switching into a forked tree 15 yards from the player will be a bit of a immersion killer :)

      FYI: I found myself thinking that the detail of the 2nd LOD away looked REALLY good, even before it switched to the extremely close LOD. So perhaps you have a bit more wiggle room within your geometry budget than you think.

      I think if the LOD transition points for the first and second levels were was pushed out a bit it would help, but I know your juggling a lot via HTTP.

      Also, if there were a way to have the transition/load from to the next LOD to be more of a slow cross-fade based upon your actual distance from it, rather than an all or nothing load-pop, it could help a lot. (i.e. moving forward 5 "in game strides " completes a nearby LOD transition, yet stopping movement midway leaving the area displaying partly cross-faded LOD 1 and LOD 2, but not changing any more till I move again... even to the point of fading back if I walk backward.

      This would make it feel more natural, like more detail as the eye gets closer, rather than the Matrix loading my scenery in a holo chamber as I move :)

      I'm sure you'll deal with the pop great either way.

    4. This has a nice side effect as well, people who look at something moving, will notice less changes than when it would stand still. In this case, the screen is moving because the virtual character is moving, if you change the LOD only when someone is moving, it wont be like DAMN! That tree just changed! But rather Did that tree just change? Hmm, must be my imagination (hopefully)

      But yea, the geometry changing and the position of the leaves as well was a bit jarring, for example, the canopy would shrink by something which would be comparable with atleast one real world meter on all sides, the leaves would move to a totally different location which stopped being relevant to the wind through the transition, and I am not sure if it was the video quality, but the quality change of the grass was sometimes a bit confusing and disorientating (If you dont take other objects into account)

    5. I agree with your observations. All this can be improved. Note that I had posted forest videos before where the LOD transitions happen in the distance.

  4. Very nice! There's more that can be done of course, but it already looks pretty believable. It'll be nice to see it when you add the proper wind simulation.

  5. Nice! Thanks for the renders! It's fun to see how much a little movement can make an already beautiful scenery feel so alive.

    Obviously wind is a lot less homogeneous than a completely global shader, and as you mentioned around mountain edges the wind would be disturbed more locally, so it's fun to know you are already thinking of that.

    My eyes say a slight sway would be the more normal state for scenes like this, but it is cool to see it all in a roil!

    A thought: Procedural "gust" entities moving around & locally modifying the direction and amplitude of the more global waves applied would be a nice way to mimic, without simulating, the windy chaos you see in real life. It would also be great if you attached a local wind/gust sound to that entity as it moves, and you'd have some very realistic looking & sounding wind, where everything is generally moving, and traveling gusts are making it appear more realistic.

    Just an observation... great work!

    P.S. I was very much missing your posts the last couple weeks! Even a smaller post like this keeps my addiction procedurally sated ;)

  6. I'm actually finding the tree movement a bit disturbing, a vegetative uncanny valley. I think my eye is reading it as "that branch isn't moving right, there must be a large predator moving about in that tree"; the effect is especially strong if I look away and just have the video in the corner of my vision.

    That said, it does look lovely, and I'm really interested to see what happens when the branches start physically responding to an external wind vector field rather than initiating their own movement.

    1. The uncanny valley can be a good sign, it means you are getting close to the real thing =D.

  7. The motion does indeed add a lot of realism. Others have mentioned the problems with the nature of the grass motion, and the amount relative to the trees, but there is another problem: the trees themselves don't move. While the trunks of the thicker trees will be fairly stable, even their branches will show some flexing, and with the grass moving around that much, smaller trees should show some flex in their trunks. Getting the trees themselves animated would probably add more realism than adding a few particles. Actually, particles might make things worse (broaden the uncanny valley caused by the lack of motion in the branches).

    Hmm, I just noticed jsgf's comment. It seems we've noticed the same problem.

  8. Nice effect, though my first thought is that in a heavy wind, the thinner branches should be moving too. My first though would be to tag geometry with a "flexibility" rating when you generate it, and apply the wind effect to various extents based on it's flexibility... But that's complicated by the fact that the about a vertex in a tree moves isn't just based on it's flexibility, but also the flexibility of "parent" geometry, tracing back down the branches to the trunk. Perhaps you could pre-calculate the sum of all the flexibility values leading up to it?

    However you make that work, I think making branches and whole trees sway would be a huge improvement to the verisimilitude of the wind. Especially if combined with the wind vectors you described, and pdurdin's suggestion that things shouldn't "snap back" as severely.

    1. Bah. Somehow missed Taniwha's comment directly above mine... Oh well, I still added something useful by suggestion a technique for achieving the branch movement.

  9. Can I suggest just using a single layer of sin/cos rather than multiplications of different ones, just like a simple lissajous motion. Using multiple sine waves introduces stationary angle effects, making it more like a robot rather than a completely random natural movement.
    Slowly moving though your fractal FBM code might do it... :)