C++ Optional Return Values

After reading this article and being inspired, I decided to write a simple “optional” class that’s similar to boost::optional but lighter weight.  The idea is that often I write functions which should return a value but which might not have a value to return — and for those cases, I should be able to specify that the return type is optional.  In the calling code, I should have the ability to check that yes, a value was returned, and get the return value.  Here’s the entire content of the class:
Read the rest of this entry »

Logging using ostream and streambuf

I architected all of my subsystems in the VDrift refactor to receive ostream objects that they use to output logging information/errors. This is convenient because it keeps all of my subsystems independent from a central logging class; all they have to know about is std::ostream. Of course, to get any advanced functionality out of this I realized I’d need to create a class that inherits from the streambuf class and then create my ostreams with the special logger streambuf. I did exactly that today and have posted the results below. The way it’s currently designed, you pass your logger streambuf a prefix and a forwarding ostream. Then, when you use the ostream that’s using your logger streambuf, the streambuf will attach your prefix and send the output to the forwarding ostream. In the future I might create support for multiple forwarding ostreams with filter levels — say I want to send some errors to the std output, everything to a log.txt file, and errors again to a stringstream that i can use to access the errors from within my program (for dialog boxes, etc).
Read the rest of this entry »

Screenspace depth-based contast enhancement effect

I spent a little bit of time with the VDrift refactor code implementing this effect:

http://graphics.uni-konstanz.de/publikationen/2006/unsharp_masking/webseite/results.html

It’s kind of like a cheap version of the Crysis SSAO that isn’t very convincing as AO, but when it’s applied lightly makes for a good improvement in apparent image quality.  The improvement is especially noticeable with flat-shaded objects.  It’s about as expensive as a 3×3 PCF shadow filter.  I turned off all of VDrift’s fancy graphics and took screenshots with the effect on and off.

The effect is difficult to see after jpg compression, but focus on the car’s back bumper.  With the effect on there’s subtle shading between the back bumper and the track.  Also, look at the big start banner and its left and right side supports — they have a little more “pop” now.  In motion in the game it really does improve the image quality, but I’m not sure if it’s worth the expense, especially in the context of a racing game where you don’t notice it very much.

Screenspace depth-based contrast enhancement effect -- effect OFF

Screenspace depth-based contrast enhancement effect -- effect OFF

Screenspace depth-based contrast enhancement effect -- effect ON

Screenspace depth-based contrast enhancement effect -- effect ON

Multithreading in Games

I added a second thread to VDrift that does only rendering.  This post on gamedev goes into more detail about how it’s architected.  It seems to work pretty well, although I sometimes get crashes when starting the thing *shrug*.  Anyway, the method by which I’m doing this is with SDL’s threads and a class I set up to give a slightly higher level approach to task-based parallelism.  I’ve attached a header for the class.

parallel_task

Radiohead visualization

Apparently Thom Yorke from Radiohead performed House of Cards from In Rainbows in front of some fancy 3D scanning device.  The resulting  data set was released online and Miles Macklin released a visualizer here: hocgl.  I did a quick and dirty port to Linux (which was not that tough), and here’s the result: radiohead-11-linux

Garritan JABB and Grover Washington

I just got the Garritan Jazz and Big Band sample library.  I took it for a test ride tonight by trying to duplicate Grover Washington’s “Knucklehead.”  This is as far as I got:

grover-rev1wav

Numerical Integration Methods

I did some research into numerical integration methods and have posted the results of my experiments in a wiki page:
http://wiki.vdrift.net/Numerical_Integration

I’m not an expert on the subject, but from what I can see the NSV/Symplectic Euler/Euler-Cromer algorithm and the Velocity Verlet algorithms both look decent. Runge Kutta 4 is too complicated, too slow, and surprisingly isn’t even as accurate as NSV/Symplectic Euler/Euler-Cromer.

An additional finding, which I didn’t post in the wiki article, is that when manually adjusting the position of one end of the spring (such as when moving a wheel up because of an increase in ground height), don’t also set the velocity based on the position difference.  This causes a weird over-damped response if you do.

Game project ideas

I was thinking about some of my game project ideas and how practical they really are without an artist.  I do have good programming skills and can write a story, but I’m no artist.  In addition, I want to evaluate my ideas based on originality, because my motivation to develop a game is greatly diminished if there’s already something out there that’s very similar.  Here’s a list of my game project ideas with some assessment of art requirements:

  • openwarrior FPS project – almost completely unoriginal, given all of the FPS titles out there right now.  I’ve been playing Ghost Recon Advanced Warfighter 2, and that game is basically what I would have made if I’d had near infinite resources.  Art requirements are quite high because multiple levels must be rendered plus some human characters that need to look good up close.  There was never any real story planned.
  • Sail 1600s project – fairly original, since I’ve never seen an historical naval combat game from the first person perspective before.  Art requirements are fairly high because there need to be large numbers of well-animated NPC crewmembers, plus a set of ship designs.  Water & land would be easier in terms of art.  I don’t have a story planned; it was a sandbox game sort of idea.
  • Space game project – not terribly original with games like X3: The Threat and EVE Online out there, but I think my approach to the genre is a little original.  If I stay away from allowing walking around ships/stations or getting too close to a planet, then the art requirements are low — just a few spaceships and some planet textures.  Again, there is no plan for a story since I figured it’d be a sort of sandbox for the user.
  • Sub simulation – not original 5 years ago, but these days you don’t see any modern sub games on the market.  Art requirements are quite low, since really all you need are the 2D interface graphics and a few surface ships.  The story would probably be something simple.
  • Castles clone – fairly original since I haven’t played any games like this recently.  Basically, it’s like the old Castles game but in 3D.  You place castle elements from a top-down view and then do battle with invaders.  Art requirements are somewhat high but this guy has already done most of the work (it’s expensive, though).  The only additional art would be soldiers, but I could probably buy a soldier and do an OK job animating those since they’d be so small on-screen.  No story ideas spring to mind.
  • Skiing game – original, since I’ve never played a good skiing game.  It’d be an open ended skiing game, with the full ski resort at your disposal, and you take lifts to get to the different runs.  Art requirements are medium to low; I could probably handle the mountain but for the skier character I’d have to buy something… but animations wouldn’t be too hard.  I think this game type specifically prohibits a story.

Unfortunately, most of these ideas have no story behind them.  I’d love to write an in-depth story, but those require characters, and characters require extremely prohibitive art, unless I found a way around that.

Idea for ambient-occlusion-like effect

The idea of ambient occlusion is that the sky hemisphere is lighting all objects, so the more that any one part of an object is in view of the sky hemisphere, the lighter it will be (and vice versa).  Crysis popularized a screen-space approximation of this effect, and their implementation seems to resemble soft shadows (projected from the view) with some additional tweaks.  That got me thinking that using a conventional soft-shadowing approach (with a large kernel blur to approximate VERY soft shadows and a quick falloff) with the light source straight above might produce reasonable AO results.  I’d like to try this out….

Multithreading Prototypes

I started thinking about how to implement multi-threading in a game engine.  My idea is that if every subsystem is independent from each other one, then the updates can be done in parallel (so, each subsystem does its tick in a separate thread).  It’s then up to the higher level system to collect and distribute information between threads as necessary, which would only be done when the threads aren’t executing. Read the rest of this entry »

Dev Journal and Project Hosting