Thursday, 18 July 2013

Thursday Terrain Video Day

After The Rain, Sunshine

Another good day of development and a decision of sorts.  My day started by reading a recent paper on a technique called CDLOD terrain (Continuous Distance Level Of Detail Terrain) which basically uses the GPU with Shader Model 3.0 to blend the vertex geometry so that successively lower polygon meshes can be substituted seamlessly in the scene. As this technique uses texture lookups in the vertex shader, it is quite hungry on cards prior to SM3.0 and perfect for the newer generation of cards which is why I liked it so much.

The technique produces almost perfect and undetectable LOD transitions, is very fast with almost no CPU hit and quite memory efficient with the possibility of streaming the terrain data in and upgrading it to DX11 tessellation in the future.  All sounds good don't it?

The downside is that to learn the technique, modify the same code to fit in as a DBP module, work out the kinks to make it stable and usable for the Reloaded project then run it through a battery of usage scenarios would take much more than the time I have left for terrain work.

Step Forward Our Hero

Once I had accepted the fact that my plan A was too ambitious and risky, I once again looked at the solution that was sitting right in front of me screaming to be heard.  After only a few minutes of tinkering, I started to realise just how powerful and complete the Blitzwerks Terrain module for Dark Basic Pro actually was.


Not only can you create extremely large terrain in memory, the automated LOD system works seamlessly, the whole system runs very fast and as a massive bonus I discovered half way through the day that it also contains a huge array of real-time terrain modifier commands. The same commands I was going to write myself until I found them in the documentation, which again was top draw and a hidden gem of this module.

The author very kindly loaned me the entire source code to the entire project, and with it I was able to quickly step through and get comfortable with the various components. This now gives me confidence that should I need to add or fix anything, it's there waiting for me. It all compiled first time and turned out to be a very well written set of projects despite a warning that it was a bit 'bloated'.

If this code is bloated, I dare not imagine what it would look like streamlined! My universe was back on solid ground and the power of terrain was bristling off my trembling fingers!

And Then There Was A Big Hole

With no time to lose I started re-shaping one of the BT2 examples along the lines Reloaded would require. A terrain that stretches 50,000 units north and east. A top down camera perspective and of course, a set of basic terrain editing features such as adding and subtracting terrain heights using a brush size based on zoom distance from the terrain to the camera viewer.  I also added a cheap and quick water table plane so I could define the land masses from that part of the terrain underwater.


At the moment all the editing controls are super crude but the objective at this stage is to get all my ducks in a row, which means get each functionality in place. We have height modification, but we also need tighter terrain height controls so I can create flat (yet blended) areas, specific shape stamps, layer level control and who knows what else. I also need to make massive strides into the texture side of things. I want a highlighter actually part of the terrain texture, texture splatting, some sort of dynamic texture renderer based on the player position so I can do LOD for the texture to compliment the geometry LOD system.

Things like the water shader and other such eye candy might also be worth doing just to please those certain mentioning no names people who get giddy at the sight of gorgeous pixels.  I have some terrain textures being brewed up a week from now so hopefully the whole thing should jump in quality as we move forwards. There is also things like geometry vegetation, terrain shadows, maybe some depth normal editing and more ideas to try out.


I also added a first person perspective to the terrain prototype so I could run around my finished creation and see what it looks like from the players point of view. It's here you realise that I will need some sophisticated terrain height editing brushes to get the kind of results most users would expect from their landscapes. Huge smooth spherical gouges ain't one of them :)

Signing Off

The next step will be to create some kind of dynamic texture system so that I can paint multiple levels of detail onto the terrain for things like grass, rock and underwater surfaces, but also normal/depth painting so I can slice very subtle details into the very texture (rather than trying to use the geometry). I can then use this functionality to automatically texture the terrain based on height so flattish areas get some grass and steep slopes get some rock. Hopefully the effect will be that painting a high grass layer above a lower grass layer will look like a raised escarpment.  See the above video of ice and rock to see the effect of a series of escarpment layers.  I am sure users will be taking control of this painting eventually, but for the user who just wants to paint the terrain quickly and start playing their game, an automated terrain painting system is vital.


For those Dark Basic Pro users following my blog, you can check out the most excellent Blitzwerks Terrain plug-in from the TGC site:

http://www.thegamecreators.com/?m=view_product&id=2286


AGK V2 Kickstarter

Rather than feed you another incorrect AGK V2 pledge total, I will simply leave you the link so you can check it out yourself. Maybe Rick will step in and provide the 'real' pledge level:

http://www.kickstarter.com/projects/tgc/app-game-kit-v2

3 comments:

  1. Just something you should stick into your todo list:

    When I was planning my FPSC2 project, I thought carefully about what terrain tools would be necessary. It occurred to me that it would be very useful to have a tool that would bring the terrain up to the bottom edge of the current height of segment. So if you've got the editor on segment level 4 and paint some of the terrain with the Level tool, that painted area would line up with the very bottom of any segments on segment level 4.

    Also - I'm very glad that you've realised just how perfect Blitz is for Reloaded. Super fast terrain!!

    ReplyDelete
    Replies
    1. And you would have, as well as the Level tool, a Flatten tool which acts exactly any other terrain Flatten tool, simply flattening any painted area to the same height as where you started painting from.

      Delete
    2. I'm often so busy I hardly get an opportunity to play with new DBP plugins, and BT2 was one of the modules I spent the most time with (and I missed a tonne of features) ;) I will probably add a new more commands for great terrain brush options. I like the idea of bringing the floor level to the edit layer you are on :)

      Delete