Monday, July 15, 2013

Voxel system update

I've been working on adding a voxel framework to our engine for use in sims where we need destructible terrain / rock. The first project that will use this technology is a continuous miner simulation. Although the framework has been in place for a while, it has only become stable (bug free and efficient) in the last week or two. I've had to do a fair bit of profiling in order to eliminate bottlenecks and boost performance (I use a tool called Luke Stackwalker, which I quite like). 

I had a gloomy moment when I first integrated it into the sim because there was a noticeable frame rate drop, but it turned out to simply be some debugging / debug visualization code I had left in. After commenting that out the framerate went right back up to a point that was actually better than anticipated considering (a) how much collision detection logic I'm running, (b) that the state of the system is being propagated through the system via state packets and (c) that I was running both dynamics and graphics on the same PC (so twice the load). It cuts through the wall pretty smoothly and the framerate is currently above 60fps.

Update: a few months have gone by since I posed this. I thought I'd replace the old screenshot with a few more recent screenshots.




Minor Updates to Surreal Landscape Demo

This weekend I did a but of work on my surreal landscape demo. I re-modelled the jellyfish (more detailed and better looking) and re-worked their animation (I'm just doing it in the vertex shader via sine and cosine waves at the moment).

I added some basic trees to get a feel of what it will look like once I start adding more foliage. I also added a bit more vegetation (cycads). I'm using instancing for almost everything at the moment, and so I'm using texture atlases (multiple textures combined into one image, with each instance able to use any of them). When setting up each instance, I randomly choose a texture offset which controls which image in the texture atlas is used. Each instance also has a random rotation, scale and colour modifier, resulting in greater variety whilst still keeping the number of draw calls to a minimum.



I also re-worked the way I handle bloom. Prior to this I had a very simple method in place, which I had hobbled together just as a placeholder until I had some time to do it properly. I was doing a Gaussian filter both vertically and horizontally in one pass as opposed to filtering first horizontally, and then vertically in a separate pass. I am doing it correctly now (separate horizontal and vertical passes) so as to reduce the number of filter samples required. Additionally, I wasn't performing the bright pass before passing them into the filter -- instead I was performing it at a later stage, in the final post-processing shader stage. This resulted in halos around dark objects, because the bloom buffer contained blurred parts of both bright and dark parts of the image resulting in darker parts 'bleeding' over into brighter parts of the image. This is now fixed (note that the screenshots accompanying this post were taken before the current fix, so there may still be minor colour bleeding present in these images).



I also decided to alter various post-processing parameters based on the time of day. I found that I could tweak the post-processing parameters to make the scene look good for certain lighting conditions, but that the lighting conditions differed significantly enough that no single collection of settings looked perfect in all conditions. I now have various sets of variables for use in different lighting conditions. These include parameters that control the bloom bright pass (bloom exponent and bloom multiplier), as well as parameters that control the very last phase of the post-processing pipeline -- contrast and saturation.

I find that after applying bloom some of the colours are over-saturated. Although I am going for a fantasy dream-world feel, I don't want it to look too cartoony, so in order to get the visual results I want I increase the contrast and reduce the saturation of the final image so as to give it a slightly more gritty feel.

Thursday, July 11, 2013

More Surreal Landscape Screenshots

I did a bit more work on my surreal landscape demo. Last night I added jellyfish-like creatures that float in the air.

The intention is to eventually have a full ecosystem which gives a genuine sense of being alive. I want all creatures to interact with other creatures and with the environment. I've implemented a flocking algorithm so far and it looks pretty good. I also have red alien plants (visible in the screenshot below) that emerge and grow at night (and glow subtly), and mushrooms that emerge as the camera draws near. But ultimately I'd like to have some creatures hunting other creatures, far more complex group movement behaviours, creatures feeding off plants or attracted to lights, more plants growing as you watch, and so on.





The demo already feels very alive -- grass sways in the wind, the clouds are somewhat volumetric and move across the sky, planets in the sky move in an (admittedly physically-inaccurate but nice-looking) orbit and water ripples. This combined with the various creature types wandering the landscape and plants growing / emerging in real-time, gives a very vibrant, dynamic feel to the scene. Still, I want much more, even if I have to only feature some elements at a time (it might end up feeling a bit overwhelming). I've also been considering having it support the Oculus Rift when my dev-kit finally arrives.

The engine uses NVidia's Cg language for the shaders, a library called AssImp for supporting many mesh formats and a library called FW1FontWrapper for displaying text onscreen (a task that is surprisingly cumbersome in D3D11). Other than that, its just pure Direct3D 11 and standard Windows calls (oh, and also Direct Input 8). Eventually I'll bring across some of my sound code from other projects, which uses OpenAL and Ogg-Vorbis (which allows me to use the .ogg format, which has similar compression quality to mp3 but fewer useage restrictions).





I've fixed my engine clock (it had a flaw in it that caused delta time to vary based on frame rate). I brought across some code from Transcendence (an old D3D9-based game engine I developed in 2008) to replace the timing code with older, more thoroughly-tested code.

There are various different timing methods available, with the four most common being the functions clock(), timeGetTime(), GetTickCount() and the Microsoft-specific function QueryPerformanceCounter(). I support all four (I can alter which one I use at run-time), simply because I wanted to test for myself which one was most reliable. Strangely, although the general consensus is that QueryPerformanceCounter() is the most reliable (albeit with some work-arounds required on multi-core systems to prevent glitches), I have found clock() to be just as sound (even more reliable than QueryPerformanceCounter() on some systems), and timeGetTime() pretty close as well.



Tuesday, July 9, 2013

Surreal Landscape Demo Using D3D11.

Much of my technical work in the last few years has been focused on work projects. Although I've been doing some casual dev at home, a fair bit has been me experimenting with making simple casual games like Shroomsters and Death Arena.

I recently registered on the "Make Games SA" site and chatted to a few people on the forums and showed them Shroomsters. One comment really got me thinking, and that was that, given my background, it wasn't quite what they would have expected from me. Looking at some of my recent technical work, specifically at a D3D11 engine I developed last year (and a bit earlier this year), I realized that it had the potential to make a decent tech demo, if only I started focusing more on the end result and less on the architecture and technical / academic aspects of it.

The engine was previously called Paradox, though I've had to abandon the name now, as another engine (a D3D11-based C# engine) has emerged with the same name. Also, apparently a team in the demoscene in the 90's had the same name as well.

I haven't chosen a new name for the engine, though at this point I don't think its necessary, since it is turning into more of a demo (and potential game... maaaaaybe). The demo will be called Clarion (for reasons that I won't go into now, but there is a story to it).

Right now I'm only about 3 weeks in, but I've made some decent progress. Here are some screenshots of the current version. I'll release more soon.

Edit: the name Clarion is apparently also taken! I suppose all the good names are. Oh well, I'll think of something.