OOK, Once I Owned a Kestrel, is now being revamped. Previously, it was to be released solely on iPhone and iPad. Now, iPhone, iPad, and other mobile devices are dropped and it will be primarily a desktop project. Welcome to the new OOK. Enjoy.

Report article RSS Feed The Procedurally Generated OOK Galaxy (And the joys of shaders)

Since the last update I have done a number of things. First off, the physics is 100% working, entities are more well defined, and basic controls are functioning. You can now fly around empty space no-problem. I also defined some basic spawning functions as ease-of-use utilities. Nothing fancy there...

Posted by teh1ghool on Mar 20th, 2013

Since the last update I have done a number of things. First off, the physics is 100% working, entities are more well defined, and basic controls are functioning. You can now fly around empty space no-problem. I also defined some basic spawning functions as ease-of-use utilities. Nothing fancy there. One last small thing I did was created a bit more of the resource loader so that I could start adding ships with the aid of the developer mode I mentioned previously.

The two more interesting things that I have done include figuring out how to procedurally generate the galaxy and using shaders to create a simply parallax effect for the space background...

In the past I created the space background by rendering a bunch of polygons and shifting them depending on the player's coordinates. To create a parallax effect (see here) I rendered a couple different layers with different offsets. However, now that I have added support for GLSL shaders, I realized that I could simplify things. With only one polygon and one texture, by retrieving texels of two different parts of the image each offset by the players position differently I was able to create the same effect. The shader is super basic with excellent results. Already using shaders has paid off!

Now the fun stuff. I explored the web a bit for equations to graph the curve of a galaxy. I found just the equation:

Quote:r(t)=(s*a)/(1-a*tan(a)*log(t/a))
s=scale
a=angle or amount of spin

Simple enough, right? Yep. I used JavaScript initially with an HTML5 canvas so that I could play with the settings until they looked right. I then generated point clouds along the line. Finally, I spawned points around each point to represent planets. The final result, plus some eye candy (drop shadows):

Dl.dropbox.com

Notice that each star is represented by a 2px by 2px dot, while each planet around it is represented by a 1px by 1px dot. You may be wondering why star systems are overlapping. "WHAT THE HELL!?" It would be ridiculously big if I represented the galaxy at its actual scale in the browser, so for the visual representation I scaled it down and scaled up the star system size a bit. The final product, once I convert it to C, will be far larger with systems highly spaced out.

Finally, I would like to note that galaxies consist of billions to trillions of stars. OOK is not that big of a game. I will not be generating a trillion stars. This will have to suffice.

Stay tuned.

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Icon
[ook] Once I Owned a Kestrel
Platforms
Windows, Mac, Linux
Engine
Custom Built
Contact
Send Message
Official Page
Spiralnebuladev.com
Release Date
TBD
Game Watch
Track this game
News
Browse
News
Report Abuse
Report article
Related Games
[ook] Once I Owned a Kestrel
[ook] Once I Owned a Kestrel Indie Single Player Role Playing
Related Engines
Custom Built
Custom Built Commercial Released Sep 1, 2007
Related Groups
Indie Devs
Indie Devs Hobbies & Interests group with 1,081 members