Monday, 19 December 2011

Big steps

So, I've made some pretty big leaps forward in the game programming: 

First half of edge detection
For the anti-aliasing, I decided to use a method pretty much exactly as used in STALKER - so far, it's only detecting edges via the surface normals, but soon it'll also use the depth buffer, to ensure that all the edges are "caught" (look at the pot on the left - its edge hasn't been detected because the change in surface direction between the two surfaces isn't great enough. Once all the edges have been detected, it's a simple and quick step to blur them and so cheaply "fix" aliasing.

This step is a post-processing step, as is SSAO. I've also started to implement SSAO, though it needs configuring for the scene, and the blurring step is still not yet complete - it has to take into account depth, or the shadows will "bleed" onto bits they shouldn't. The final steps are exposure and colour correction - colour correction I've already done, but in lower-quality versions, and exposure is still in the works (fixed exposure only works at the moment).

I also wrote most of the intersection tests, which are going to form a fairly important part of the physics system, level layout and rendering optimisations. The overall plan is that every object in the world will be given a "bounding box", and quickly checked against the feature in question (for example, for checking if an object is visible, it's checked against the viewing frustrum, or for physics, a ray representing the motion of an object can be checked against anything it's likely to collide with). This can be optimised by including all objects in a "tree" of bounding boxes, where each bounding box node completely contains all of its children, so if the parent is outside the area in question,all of its children can be quickly eliminated.

The framework for a download and resource manager have been started - allowing files to be queued and made to download or update, and for resources no longer visible to be unloaded completely to save graphics memory.

I also tidied up the controller code somewhat for Windows - it can now get the proper analog values, and detect the type of controller and battery level (and interestingly, also the type of battery in the controller) of Xbox controllers. Almost completely pointless but cool nonetheless.

Finally, a teaser, most likely for next time:
No clues as to what this is for yet, but it should be interesting...

14500+ lines of code now, 333 TODOs listed.
Charlie

Monday, 12 December 2011

XInput

 So, I spent far too long working on getting the Xbox controller working - instead of using their standard input libraries, Microsoft in their infinite wisdom chose to make a separate API for the sole purpose of interfacing with their controllers. As a result, I ended up downloading a C++ IDE, and using Java's native code to work with those APIs. On the plus side, it means that the vibrate and separate polling of the triggers can be done (using the previous method, only Trigger (R-L) can be read not R and L separately) , but under Windows only.

Other than that, I tidied up the native code loading further - it now "cleanly" loads nearly all of the dlls or modules needed to run independent of platform and architecture (I still have to fix nativewindow though). Lights are now configurable in the engine rather than hard-coded into the shader (simple change but an important step), and I've started to write the basic game code/world itself.

Stuff I still need to do:

  • Intersection tests/resolver for physics, area scripting for levels
  • Scene optimisation
  • Decent gameplay code
  • Improve the importer (bring lighting, more material properties in)
  • Finish lighting optimisation - actually do the stencilling - additionally, light clip volumes
  • Antialiasing
  • Shadowing
  • Audio


Charlie


Monday, 5 December 2011

Small Steps

So, I finally sat down and spent a couple of hours coding the engine. I've started to tidy up my code layout and sort out decent input and gameplay - and in part of that, I bought a USB Xbox gamepad and played around with using it as an input. Unfortunately, the rumble feature is broken in the library I was using but otherwise, the controller works nicely and gives a nicer feel to motion - it's much smoother than a keyboard, and seems a fairly natural way of controlling a platformer-style game. I also added some very basic mechanics - nothing more than the basic laws of motion at the moment, and nothing visual either. 

Still planning to have something "playable" (i.e. vaguely resembling a game or game engine) by the end of the year if all goes well...

Charlie

Monday, 28 November 2011

Super-Secret Project

Another terribly-short-and-limited blog post to follow, so I don't blame you if you skip this one. Work, parents' evening, and the super-secret-project have been taking up most of my time. In no particular order, I have managed to:


  • Sort the 3D printer bed out - glass cut and bored successfully (or nearly finished, need to tidy and finish the holes)
  • Nearly-finish the lighting optimisations - stencils are now working, and now just need to fiddle around with how the information about lighting is stored (radius, colour, position, shadow-casting)
  • Finish most of the programming on the super-secret project for the time being. Hint: it involves multiple virtual servers, a simple database, plenty of permissions, various types of buckets, and voxels. 
  • Buy far too many games - RAGE, Amnesia, L4D2, FEAR series, and a couple of indie titles. I might do a mini-review when I get around to playing them.

I leave you with an incredible video - worth watching in HD.


Charlie

Monday, 21 November 2011

Bugfixes

This weekend, I got to see a legitimate Robot Wars battle at the NEC - two flipper-armed robots throwing each other (and themselves) around. I also saw and spoke to a couple of engineers on the Bloodhound SSC project and saw the vehicle itself.

On the game, instead of coding anything new, I went through some of the very worst bits of my code and carefully removed a few of the worst-offending bugs.

  • The first one was that resizing the window would not resize the stencil buffer, resulting in some fairly unusual artifacts appearing. It took me a fair while to notice that I was actually allocating the buffer twice, and corrected it. Now I have stencils, which makes culling pixels for lighting very easy now.
  • The second one was a silly mistake in how I handled texture path names. I'd been doing it in a silly way (hard-coded slashes, which is death for cross-platform compatibility) - I went through and replaced most of them with the appropriate platform-independent solution. 
  • The final one was a complete pain to find and kill - I found that when changing camera angle with bright lights in the scene, the lights would flicker in a fairly irritating manner. I checked and double-checked my entire lighting code several times, as well as the matrix transformation, before realising that everything was (surprisingly) perfect. The actual issue was that my normal buffer was at too low a precision to make the lights adjust properly over a wide range of viewing angles. Unfortunately, a side effect of increasing the precision is that the lights now take longer to process - now, 800MP would seem to take (very approximately) half a second to run, giving me 16MP to use for lights, not 32MP (which is fair, given that I doubled the bits). It remains to be seen whether changing some of the other calculations (inverse of the matrices, reprojection, etc), lowering precision (8-bit floating not 16-bit floating buffers) and/or constraining the areas will be enough - though there's no reason it shouldn't. 

I also managed to fix George's PS3 for the second time and started work on a super-secret project, which is going to be revealed fairly soon (on or before next week).

Monday, 14 November 2011

In Motion

The printer is finally moving of its own accord - I discovered a work-around for the firmware issue. Connecting the Arduino via USB, connecting in RepStrapper, and then finally applying power to the shield allows the board to connect. The thermistor readings work fine and I'm pretty sure the heater MOSFETS do too, but the stepper boards get too warm to work effectively - I should have some thermal epoxy and old aluminium heatsinks spare to sort that out, though I dislike making any permanent changes to hardware (and that glue is just about as permanent as it gets). At the same time I should also be able to heatsink my 1W laser driver too, and get some pretty pictures of the beam at full power, without it cutting out as the thermal limiter kicks in. The only other option is to buy a new and higher-power circuit instead (torches have higher-power boards but with much less tight regulation, which should be OK for a tough laser diode, though it may shorten the life-span somewhat).

I've also played with the lighting shader code, and worked out that changing the data types (the "quick fix" solution to the lighting speed) is simply not enough to bring the time down to reasonable lengths - it saves a about 2 ms for 800 million pixels - not nearly enough. The only reasonable solution now is to apply the lighting calculation to less pixels - using an estimate of 0.75ms/4MP, that means that lighting can "afford" to light about 32MP and still leave enough processing time for pretty effects like depth of field, ambient light, SSAO and another lighting or material pass for skin, particles, and other effects. To restrict 100 lights to 32MP, the average visible light radius can be around 300 on-screen pixels, which is pretty reasonable - in a cluttered scene many of the lit pixels will be occluded anyway, so drawing the light with a depth comparison might save even more processing time. Shadows are also relatively cheap with this method but will still need careful planning. All of these estimates are based on a fast card at high resolution though, so others' mileage may vary.

Charlie

Monday, 7 November 2011

Thermistor Trouble

In the last week, I've added multi-lights, tidied up my current lighting method and planned/written the beginnings of a skeleton-loader - the Doom 3 format is particularly nice for my purposes. Lights are currently too inefficient - 100 simultaneous non-shadowcasting lights run at about 7fps at 2560x1600. Admittedly, I've taken some horrific shortcuts in the pursuit of simplicity (right now, for every pixel on the screen, for every light in view, it generates the inverse of a 4x4 matrix - not exactly a speedy process).. When I fix that particular source of inefficiency, I'll re-time everything, add shadows, and see if it still needs more work. After that is skeletons and game logic itself.

As for the 3D printer, I (badly) drilled the holes through the glass bed - it's still usable, but has some irritating cracks. The firmware is unfortunately proving to be a bit of a pain - I haven't managed to get everything working reliably. I remember having a similar issue previously, which I think ended up tracing back to the thermistor board, of all places. The board currently sends back a "start" signal, but doesn't do anything useful afterwards, and drops the connection. With a bit of luck that issue shouldn't take much more time to trace down and I'll be all but ready to print!

 Charlie