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

Wednesday, April 3, 2013

The sun rises in ProcWorld

So I finally added some proper light scattering to the sky atmosphere in the realtime demo.

I am using the classic approach devised by O'Neil, which produces great results but it is also very sensitive to any change in the input parameters. A lot of tweaking is still required.

Here is a series of shots, keep in mind this is a work in progress but any early comments surely will help.



  1. This is looking great. The colours all look very natural, except for perhaps the last one. The ground looks more purple and the buildings look a yellower shade. Is that expected? I guess it's just the yellow of the sun striking the walls before it hits the ground.

    I'd love to see some clouds in the sky for added realism, but how will that go with the lighting effects?

    Hey, will Voxel Farm end up working on Mac as well as PC? I've been following this for a while and have my fingers crossed.

    1. Yes I see what you mean.

      Mac support is a maybe, only if everything goes great in Windows.

  2. Well, it kind of makes it feel like the world just drops off after those mountains, as if the sky is really close. The moon is also... strange, perhaps its too disc-like? Too sharp? I dont know precisely what it is. If you already noticed this yourself, good =D, if not, well, there you go.

    As for atmospheric scattering, I found an article about it lately, didnt read it myself, but the results look really fancy, so it might be worth looking at:

    1. Thanks for the link, really nice article.

      The moon is a placeholder for now.

      You are right about the sky feeling too close. I will see what is causing this.

    2. More on the'close sky' i think the edge of the distant mountains that separates land from sky seems too hard in pics 1 and 2, contributing to the close sky effect, and yet the hard edge works very well as a silhouette on pic 3 and seems perfectly appropriate. Don't know if that's any help!

    3. (by the way i used to post on here as johng, I've done some updating on my google profile and google have seen fit to update my blog posting too !)

    4. I guess it still feels to gradient like, What i feel is missing is clouds and random noise that distributes light a bit more.
      Also if you thing a little bit about how light works when it hits your eye.
      Chances to for photons to hit the eye is much higher when close, being far away in the dark should shows a small decrease in light.
      So if you have a depth buffer or something, it would look more natural if the far away objects looked more darker in the night.

      Also depending on the height of the camera point, you could do some kind of gradient calculation of diffrent gaslayeers in the atmosphere. with gas density and color, it could look pretty realistic.

  3. Colours are great! But all the skys (except maybe 3rd and 4th ones) need to be much brighter, at least twice as bright. If you slap a plain white diffuse object in there, the sky should be brighter than the brightest part of the cube.

    All of em look a bit too saturated as well, but brightening them up might fix that

    A quick gimp later and it makes much more sense to me now:
    That's twice as bright and maybe 20% less saturation

    1. I share Greg's suggestion. Beside the general awesomeness of the shown screenshots they seem to be a little too dark and saturated. I'd prefer Greg's version intuitively as more realistic. But maybe the whole impression changes with clouds, stars etc. ...

    2. Thanks Greg, this helps a lot. I will change it.

  4. Your gimpification seems to have made the edge between sky and earth a bit vaguer (foggier?), even if that wasnt on purpose, it looks better =D.

    1. It was slightly intentional - what you're seeing is called 'light wrapping' where the sky bleeds slightly over the horizon (or whatever is over it). Sort of like a bloom/glow effect.

  5. I agree with Greg as well, but that may be because how the sky is calculated/rendered than how the sunlight is rendered. The sky always becomes lighter or hazier toward the horizon than it does looking straight up. Looking cool though.

  6. This comment has been removed by the author.

  7. It looks good, if you have the time, it's worth checking out precomputed multiscattering.



    It took me around 8 hours all up to get it working and integrated with my engine, and I'm really happy with the results (I found the single scatter model from GPU gems too dark/fiddly).

    1. Thanks, Kamika posted this paper a few hours ago, now you have included the source code... it is like Christmas!

      Yes O'Neil's is it is dark and fiddly, especially when you are in the planet's surface.

    2. Theres a C in there XD.

      Anyway, I figured, if we give you articles and stuff of awesome stuff, you will possibly implement said stuff, and we everybody gains from it eventually! =D

    3. Those papers, and their comparisons between real and rendered results are pretty awesome! If that can be implemented pretty cleanly I'd say it'd be worth not reinventing the wheel, it's gorgeous!

      I love that work like that is being shared. It is going to help the industry move faster -- so experts in other areas, like Miguel with procedural landscapes and architecture and realism, can spend their valuable time pushing boundaries in their own areas! :)

      Good work!

    4. I was looking at the precomputed scattering approach. How is this faster than O'Neil's? Yes, it does not need to iterate but then you must run this on every fragment, whether O'Neil runs in the vertex shader.

      In the paper they claim their stuff runs at 125 fps versus 50 fps for O'Neil, but I wonder if they were running O'Neil on the fragment shader.

      I guess you could move the precomputed tables to float luminance textures so they can be accessed by the vertex shader, but that does not seem trivial... surely more than 8 hours.

      Are you running this in vertex or fragment shader?

  8. An artistic observation: shadows are what make light work, visually. The "best" shadows require a certain amount of angle in order to work.

    If you want things to be the best looking and also the most user friendly, you want to fudge your lighting a bit. Logically, the sun will move at a constant rate across the sky. But it's fine for the actual light source to be a little off from the sun sprite.

    Imagine the speed of the sun sprite being laid out on a graph of speed vs time: it forms a straight horizontal line. The actual light source though, if it moves at a variable speed, it would form a sine wave, with a valley in the morning and afternoon, and humps at noon and sunrise/sunset.

    The thinking is that you want to minimize the amount of time that you have very long or very tiny shadows. The actual light source moves slower in midmorning and midafternoon so that you can get the nice, contrast-supplying shadows for the greatest length of time.

  9. Just been looking again at the pics, one comment I'd like to make about the last pic- the illumination of the rocks and building in the foreground looks like it's from a very large, close up floodlight, rather than distant, from the sun. I'm afraid i don't know any technical terms to quantify the effect, but the light looks too 'focused' (that may not be the right word) to be sunlight, which I'd expect to spread more evenly over the foreground objects. Sorry if I'm not explaining myself very well! I hope you understand what I'm getting at..

  10. Guys I really want to thank you all for the help. All your suggestions are spot on, there is no need to be replying to your individual comments.

    Some people complain about the difficulties of developing in the open and showing their unfinished work. While this is true, I think sharing with knowledgeable people is what makes all the difference.

    I really appreciate your help.

    1. The big problem with developing behind closed doors is that too often people will eventually release mediocre "finished" work because they haven't had the humility to listen to others. You seem quite willing to admit that you can't get everything right off your own bat, that others might see or explain problems better than you've managed by yourself. And this is one reason why I keep coming back to your blog. :)

    2. A lot of heads, processed and refined by one smart head, can make anything possible =D.

  11. Do you have any plans for licensing your engine? Some kind of alpha subscriptions or kickstarter project?

    1. To save Miguel the reply:

      Yes he's creating this to eventually be a licensable engine. Currently he is working towards all the underpinnings, while working toward game-ifying it enough to support some mechanism for monetizing it's next steps with a demo of sorts.

      Whether he is planning on Kickstarter, or something else, he isn't yet ready to say, and it's not available yet. Either way, it will be an engine, but he's "eating his own dog-food" by making himself work towards a game of his own in it.

      The game will probably be: procedurally generated and voxel based, sandbox style, single and multiplayer capable, fully deformable terrain and procedural content -- within which you can explore and build both above and below ground, in a varied world.

      Should be fun don't ya think?! ;)

    2. Wow nice job.

      Some aspects of the engine are mature by now, they have been licensed by some studios. I am not at liberty to say at this point.

      A kickstarter or paid alpha will come at some point, but it has to be a lot more than an engine demo. This needs real gameplay elements and a clear vision everyone can understand. Otherwise I am not comfortable asking for funds.

    3. Cool, thanks.
      I guess prices aren't hobbyist-affordable? :(

  12. Sorry I'm so late. I think the problem with the last image is that the background is not lighted enough. As John Gill said, it looks like a light is much closer to the foreground objects, where the Sun should illuminate everything in the scene pretty evenly.

    I think the "sun" should be much "further away," i.e. the light should be much more even over the entire scene. I think this problem applies to all the images, too, it's just most obvious in the last one.

    I'm excited to see this in action!

  13. To add to the input (long time follower, first time poster?), outside of the diffusion and brightness, a very real issue is the pixelation happening at the edges. Of the ranges, I assume because of the distance. There is very apparent stepping going on, and it causes your mind to try and interpret it as something different than what it is. You can see this effect on the image of Machu Piccu below:

    In particular, note the "pop" of the background mountain against the man made structures versus the lack of "pop" against the natural range on the upper left side.

    For fun, implement something similar in your engine and see how it looks. I'd bet money that you'd see the same effect going on.

    Another good example, closer to your imagery issue:

    Not the parts that have had time for nature to grow over them versus the part that has broken recently in the upper middle and the disconnect between the backdrop.

  14. Looks great. I can see the banding, but really? It looks fine. What, we're not already expecting photo-realistic lighting solutions are we? Heh.

    My only concern are the plants in the lower right. In pic 3 of 5 they really seem to stand out unnaturally from their surroundings. Almost like you're drawing them separate from the terrain and then applying their lighting differently.

    Are the sun/moon casting terrain shadows? I couldn't tell from the pics.

    1. The importance in computer graphics is not how good the graphics are, its how consistent the graphics are. Because Miguel made such a detailed world, making a less detailed sky just makes the sky look ugly.

  15. Hey there, also a long time follower. awesome stuff!

    about the sky, I have some issues with it. I already saw some people commenting about the "close sky effect" and I think I know what is causing this.

    It seems there is a problem with the atmospheric perspective overall.

    It looks like the mountains in the back have less contrast and saturation than the sky and this makes it look strange, it destroys the feeling of depth.

    Also, the sky is actually darker than the mountains, and this is almost never the case (exept with storm clouds or very direct lightning on the mountains.

    furthermore the hue looks strange, especially on the second one. The mountains should actually recieve the hue of the sky but in this case the mountains are a orangy hue but the sky is a bluish hue which doesnt make any sense.

    I think it will help a lot if you do some research on arial/atmospheric perspective in general.

    I hoped that made any sense to you, I find it harder to explain than i thought.

    keep it up!

    1. I found this video, it explains is a lot better than I did.

      (especially from 3:45)

  16. this is a bit offtopic, but will there be linux support? i really hope so as at some point i really hope to give you some money.

    also mod support wise, how will gameplay coding work? will there be any kindof easier tools for artists to mess around with gameplay elements? i understand if you dont reply to offtopic posts, but im just a bit excited for your engine and am wondering how much there will be to play around with in terms of dev tools. thanks so much and your stuff looks better and better everytime. also hope have a server and hope to run an instance of your game whenever its released.

    1. Well the code base is in C++ and OpenGL, with some effort it could ported to Linux and MacOS. The networking and storage components are tied to Windows as they use very specific OS features. The same features exist in Linux and MacOS, but they need to be used a bit differently. So there is more work on that side.

      As I see it, it really depends on the demand for it. My approach is whatever comes out of this has to be successful in Windows which is the larger market. Then I would consider ports.

      As for mods, I really want to open the system as much as possible. This design keeps me up at night. My idea is to have a small closed binary component that does the core and difficult things, like octree and scene handling, conversion from voxels to polys etc, then have a stack of components on top that produce voxel data, add rendering passes, etc.

      These components could be entirely open. If you had some C++ skills you could compile them, create new ones.

      For instance, someone could write a component that allows you to connect to a Minecraft server and experience that world using the engine.

      Or, someone could replace the default terrain by something of their own, or add new layers to it.

      I am even considering using Windows UAC system so these plugins are part of the world definition and can be run securely. That is, the game would run as a low-integrity process so it would not have real access to your HD, windows registry, etc.

      This is a dream at this point. Still as you can see it revolves around Windows.

    2. I'm really looking forward to test it :) ( if it will be possible :P :) )

    3. Few things to consider with linux :

      -Windows 8 adoptions is worse then Windows Vista
      -Steam is coming to Linux in a big way,
      -Server market is still dominated by Linux, if you want your game to spread, dedicated linux servers are a way to achieve that.
      -Linux gaming market typically is very generous monetarily and with code assistance if you can meet it halfway atleast.
      -My friends and I really want to buy your stuff, we are all on linux.

      I really hope you take it into consideration, I think your work is the most exciting I have seen this year and last. To have it stuck in a windows only space would be a shame.

    4. what i meant to say, windows 8 adoption is worse then vista right now at this moment

    5. Yes by all means Linux is a serious platform. In an ideal world I would be maintaining Linux versions in parallel.

      In practice I need to choose between that or adding new key features to the Windows version.

      Another way to look at it: If this fails it is because of botched game mechanics, lack of interest, bugs, etc. Lack of Linux support hardly qualifies in that list. I have no choice but to secure the critical path in at least one platform, and I have chosen PC.

      (And yes Win8 adoption sucks, but Win7+WinXP is still huge)

  17. That looking great! Make clouds in the sky and invite testers!)

  18. first time i hit this blog was about an hour ago ... I just picked my jaw up off the floor ... WOW !

    ... minecraft ... lol ... nothing on this !!!

    Seriously, that's talent!

    So when can I get hold of this?
    The annoying this is ... I really need something like this right now but I doubt i'll ever be able to afford it and i'm sure as hell not smart enough to write it.

  19. Really great job ! Application of your project like the voxel storing part could be used for other purpose than gaming (ex scientific)

    How do you compile your project ? Do you use cmake or visual studio compilation project ?