Saturday, October 22, 2011

HDR procedural starfield Pt1

Firs there were star fields. Then there were procedural star fields. And now, I present to you a HDR procedural star fields! "Murr?"

Nothing too fancy, but in the day and age of modern HDR rendering and graphics, why shouldn't we have fancy star fields for space and nighttime levels? Think about how neat it would be when you have an environment where you're standing in an area with a lot of light polution, you only really see the brightest stars in the sky. Then, once you're in the clear and your eyes adjust how many more stars you see. Maybe even through night vision.

Recently I've started playing through Kotor 2 for the first time (after many years or owning the game), and one thing I saw in the early spacewalk scene was just how uniform and regular all the stars appeared. This in itself is somewhat jarring since even if you were in the centre of the galaxy, you would never get a star pattern quite like this. What a great place to use this kind of process I thought!

The method of generating these stars is pretty simple, really.
  1. We assume that the viewers perspective is more or less aligned to the galactic plane.
  2. There are stars above and below the viewer, but the majority exist along the "horizon"
  3. Some stars are brighter than others.
  4. Most stars are actually very dim.
What we end up with is a uniform distribution of dim / medium dim stars everywhere, and then progressively brighter stars near the galactic plane. It's definitely a starting point! Once I find the source code I wrote (and should have backed up onto a NON-portable medium (DOH!!!!)) I'll post freshly generated examples :D

On the technical side, I use doubles and floats to calculate everything, and then render the results to a 128bit, 6K x 8K DDS file. I could go more, but since I was using a 32-bit compiler I think I was running out of memory allocation O_o

I chose to do 32bit RGBA and sample real world (real space?) star data to get a more realistic distribution of star colours (temps) and luminosities. And while I COULD just as easily do a single 32bit gray scale channel, I think RGBA is much more fun ;)

From then on it's possible to tune and add general brightness variations in Photoshop (as long as it doesn't crash trying to open the 130MB+ DDS files), and add things such as nebulae, dark dust, etc.

About the biggest limitation of this custom build starfield generator is my own programming ability and lack of necessary math skills to be able to create this star field in a more useful longitude-latitude orientation. Or even a cross style cubemap where stars respect boundaries. It's something I intend to learn because it will greatly increase the fidelity of the starfield once it is transformed into those types of maps.

More on that in part 2!

Linear histogram

This is something that I came up with (I think) for my own entertainment, but I think it might have uses elsewhere as well, somehow.


We all know traditional histograms:
Well, what would something like this look like when applied to video, and rendered over a linear timeline? Basically, look at the histogram from the top and make it a thin 1pixel by 256pixel strip. Go to frame two, do the same thing, and so on, and so on. The results can actually be very interesting!

This is the first 1024 frames of an Unreal speedrun. You can clearly see where the action is, where the player gets hurt, etc.

I'm not sure if this is something that actually HAS a name or not, but I call it a linear histogram. As for any practical application, well, I just find it interesting to look at, especially for highly saturated videos like of speedruns of FPS games. Real world videos aren't nearly as interesting looking, but then again I'm not approaching this from any practical application angle :) but others might.

As for the program I used to render these, it's a c++ application which uses OpenCV 2.3 to video videos. Then it's a simple matter of counting pixel intensities each frame, performing square root and normalization on each channel, and then writing the results to file.

The source code isn't anything too special, it gets the job done, and I'm sure someone who is a lot more technically proficient can make things run a lot more smoothly. I'll post it once my server IP updates again (If you do intend to run it, make sure you have OpenCV 2.3 installed and setup!)

That's all for now!

Reintroduction

So it's been a while since I've posted anything, but a lot has changed since then! First off I've wrapped up my work at Next Level Games and started a new adventure at EA canada as a full fledged technical artist, woot!

I've had a few projects on the go as well, just personal things that I find interesting and give me a chance to learn more technical skills. I'll post about them in successive posts since this is just to get thing rolling.

One of the reasons that has prompted me to get back into blogs is Extra Credits. Really, if you're into games (Or want to know more about the passion / problems in the industry) watch extra credits!! It's brilliant! I know I've heard of them when I was watching the escapist, but I haven't actually watched a single episode up until a few days ago, and I was like "My mind is blown!"

So yeah, with the intro out of the way, it's time to get into some more details as to what I've been up to outside of my family activities :)