Tuesday, September 23, 2014

NEW Spacescape gets HDR, OSX and more

Version 0.5 of Spacescape has been released -  Download it!

If you were waiting for Spacescape to run on OSX, your wait is over! Not only is it over, Spacescape got some requested features that are really cool.


  • Support for OSX
  • HDR mode for working in high dynamic range and exporting 32bit per channel .exr or .dds skybox images.  Also allows for using HDR billboards (.exr)
  • Import billboard data file to manually specify billboard positions, brightness, distance and  colour
  • More export options! Export now adds support for UNREAL (3d cube map with correct rotations and .dds output), UNITY (correct naming), SOURCE (correct naming and .tga output)
  • Debug box option for those trying to determine the orientation of the exported skybox faces for importing into a different engine
  • Converted billboard file field to support a browse button so you can choose any file on your computer instead of having to put them in the media/materials/textures folder

About this HDR thing..

You can thank the good folks at NVidia Demos for financing the addition for a recent demo they released!  You can see part of the Spacescape generated HDR starfield with actual star values, positions, brightness values, colours and some generated nebulas around 6:54.

It's really cool, but for most games you'll probably stick with non-HDR because you just don't need the extra data.  HDR skyboxes are cool when you want to accurately adjust the exposure in your game for, say, a daytime scene when the stars are not visible because the atmosphere is so bright, and then as night comes and the atmosphere is no longer bright the stars become visible.  Keep in mind a few things:
  1. Use HDR billboards in .exr format or the outlines of your billboard stars will get too blown out as you adjust the exposure.  Some sample .exr billboards are included in the app or you can make your own in Gimp or Photoshop.
  2. Use the new HDR Power field to push most of your stars into the background if you are using randomly generated star positions, otherwise use a data file.
  3. If you use a data file to specify star data, the input is a csv file that requires an X, Y, Z, ABSMAG, and DISTANCE.  All these values are based on actual star data and there is a sample data.csv file with a few constellations in it in the Files section of project.  You can also find a massive star database at http://www.astronexus.com/hyg
  4. Use HDR Multiplier to make background stars and nebulas really faint and near stars bright
  5. A good range for HDR brightness values is between 0 and 10, even though the colour values for stars is from 0 to 255, when in HDR mode those numbers are actually converted to the 0 to 1 range then the HDR power function is applied and the result is multiplied by the HDR multiplier.

There's lots left to do

And that's an understatement.   Spacescape is nothing like the final tool I want it to be. I want to implement a simple mode for non-wizards, and a skybox library - a way to share skyboxes from within the app amongst many other things.  I'd also like improve the way layer masks work and possibly add terrain and planets!


To add all the features I want would take a lot of time.  I was only able to add in these recent features because Nvidia was able to help pay for those hours.  So I'm considering putting up a kickstarter or indiegogo project to get the other features funded.  Maybe nobody will notice? On the other hand, Spacescape has been downloaded 41,000 times since I posted it in 2010.

Monday, August 11, 2014

Adventures in Phaser.io

With the Christian Game Dev contest coming up, I decided to use a game engine I've wanted to use for a while.  There's a web game engine called Phaser, written in Javascript that uses Canvas or WebGL for rendering and HTML5 for audio.  The documentations and community is awesome, they even have an IRC chat room where you can get instant community support!

The Competition

For the competition theme this year, you could pick from one of three verses.  I chose the Hosea 6:6 verse which says something like, "For I desire mercy, not sacrifice, and acknowledgment of God rather than burnt offerings."

Yer a pirate yarg!

In my game you're player is a pirate and you go around collecting treasure and fighting while running from the King's men.  At one point you get caught, told the truth and are given the option to be pardoned and join the King's men or be banished.  After you join the King's men you are given a new sigil, clothes and a mission to recover the King's treasure/keep the peace and offer the same deal to any other pirates you encounter.  Get it?  I know, I'm no C.S. Lewis, but it's one of my favorite CDN game ideas so far.

I spent too much time on creating assets and just figuring out how to work with Phaser, and then went on vacation half way through the allotted time, so I never finished it.

Pirate sprite sheet

I used Tiled for making the levels, photoshop for all the art and did my coding in Sublime.

Custom props!

In the end I would say that Phaser is a good engine for creating a web game.  It has just about every kind of example you need to make your 2D game.  The downside of Phaser, for me, is that it is written in Javascript and I have yet to find an editor that I really like for Javascript.  XCode has ruined me with it's code completion and super easy navigation.  With Phaser, I was constantly flipping back and forth between the API in browser and Sublime, where as in XCode I would use auto-complete or cmd+click my way to the header files for whatever I was working on and rarely have to use my web browser for anything.  Sooooo much faster!

If you have to chose a platform for a web game, I'd say Phaser is one of the best I've seen, but if you don't really care so much about open source and not needing any plugins you can always join the herd and head over to unity3d.com

Tuesday, April 1, 2014

3D Puzzle Game "PZL" Released!

Back in, oh, last year I threw together a game for Ludum Dare 26 called "Puzzle Cube" that was built entirely on Ogre3D.   Shortly after, I ported that game to iOS and showed it to a friend who really encouraged me to develop it into a full-on mobile game with levels, scores, and everything. Since then I've made 30 code commits and added a bunch of features and levels and released it on the iTunes Store  under the official name PZL.  Dayum.
Well actually, in PZL you control a glowing blue orb that starts at the base of the puzzle tower.  Each level of the tower can be rotated so you can move the blue orb up till you reach the end of the level - and eventually the top of the tower.  Along the way you'll discover tunnels through the puzzle, prizes, and monsters to evade.

The Journey.

So how did a game that started out looking like this:

Ludum Dare 26 - PuzzleCube
Get to this?

First of all, porting to an iOS mobile device when you start out with a Windows build isn't a walk in the park.  In Windows your render loop is probably some endless while loop or frame listener.  On iOS you have an Objective C app that sets up a CADisplayLink callback on a frame interval.  The callback then manually instructs Ogre to renderOneFrame.  Then there's the matter of getting input from the keyboard, touch input, outputting audio, not to mention any kind of networking or saving to disk you might need - ouch!

Let's talk bout some of those -


I used the OgreDemoApp/OgreFramework for iOS as a base so I had to refactor my initialization code so it worked with the OgreFramework.  I had to pass down some things like the scene manager, camera and window handle to my main game class.  I also decided to make my Game class a singleton mainly referenced through the OgreFramework so I could easily pass down frame render events and input events from OIS, but I probably could have architected it all differently and merged my main game class with the OgreDemoApp class.   The downside of merging would have been that I would have a lot more code in that merged class that wouldn't get used on say the Windows version.

Also, I had to remove all the OgreBites tray code and the majority of the camera manipulation so my game could control it instead.


Things got a bit hairy when I needed to expose some things to C++ code that were only available in Objective C, namely audio, keyboard input and session data (stored in NSUserDefaults).

I chose to use the SimpleAudioEngine for audio which comes from CocosDenshion (Cocos2D also uses this).  It's a really simple audio player that easily handles background and event audio.  So how do you access an Objective C class from inside game code which is written in C++?

What I did was create a GameAudio Objective C class:

The implementation file for GameAudio (named GameAudio.mm) has my functions that call the SimpleAudioEngine class like so:

To call those GameAudio functions from C++ I provide another header file called GameAudioInterface.h with headers for the functions in GameAudio.mm

Keyboard Input

WARNING HAX.  I created a GameKeyboard Objective C class with an invisible UITextField added to the main UIWindow.

Inside the implementation file I provided functions to show/hide the keyboard and called functions in my main game code when a key was pressed.  Because the game code used OIS I had to map every character to the OIS equivalent. YUCK.

Lastly, I exposed the keyboard show/hide functions in a header included in the C++ game code called

Hopefully that code saves somebody some time.

Other  Objective-C Stuff n' Thangs

OK besides audio and keyboard libraries I used NSUserDefaults to save some basic settings and the excellent Scoreoid API for saving player scores.  For those who are unaware, Scoreoid lets you save scores for free using their platform agnostic API so this means if I port the game to Android I can access the same score data in the future.

Lastly, I implemented the Chartboost SDK to serve ads.

Technology Used

Graphics Engine: Ogre3D
GUI: Gorilla
Input: OIS
Audio: SimpleAudioEngine (CocosDenshion)
Scores: Scoreoid
Animation: CppTweener
Network: AFNetworking

That pretty much about sums things up as far as the development goes.  I do plan on adding some more gameplay elements in the future if the game has enough of an audience to warrant updates.

You can download PZL via the iTunes App Store on your mobile device or click the link here:

Thanks and enjoy!