Sunday, February 23, 2014

Game Gods

Old mcPhart

As if it was only a few years ago, I can clearly remember how my little brother and I joked and always called our dad "grandpa", to tease him. All people somewhere above 35 were called grandma or grandpa anyway. Old people who grew up with the Beatles in the black&white era, getting bold, without much fantasy anymore, reading a book or falling asleep instead of playing with Lego or Nintendo. Complaining about rules, school and "wait till you're a little bit older!". Yep, grandpa-symptoms all right.

My daughter is getting near the age we used to be when calling our parents old and crippled. And although I became a father relative young, I also passed the 30-years border a few days ago. It's just a stupid number and usually I couldn't care less, but at the same time you do realize that "fun-time is over". Not entirely true of course, but looking back, it's just statistically true that:
- aged 0..4: the "dark shit" ages
No explanation needed.

- aged 5..10: the magic ages
The world looks, feels, sounds and smells like magic. All very new. Sometimes scary, sometimes beautiful. But mostly pure, and without much care. That's why everybody still loves you.

- aged 10..18: the "experience" ages
Turbulent times. You develop your character. You know everything better and despite your parents telling smoking is bad, drugs are bad, alcohol is bad, and girls stink, you do it all anyway. Screw them. And if you can't win with arguments, you cry and yell like, exactly, a spoiled teenager. The world is about you.

- aged 18..30: the "getting mature" ages
My first job! My first school degree! My drivers license! First time getting a man with a woman in bed! First illegal house party! First vomit over your friends shoes! First keys from your first house! First baby... We had fun all right. But moreover, unless you screwed up really bad in the experience ages, the puzzle pieces should fall together now. Hey, you're growing up finally!

- aged 30+: the "getting older" ages
Yeah... what to do now? At this point, you probably experienced and learned most essential life lessons. You climbed to the top, watched over the landscape, smiled, and now decided to go back and settle. Stability is what you're looking for. You know who you are now, you know your limits, you know there won't be much more drastic changes or milestones to come. You start realizing "this is it".

- Aged 50+: the "complain" ages
Back in the days everything was better. People were more friendly, women less slutty, kids smarter, politicians more honest, cars more shiny, folks less greedy. You miss those days. And who to blame? Exactly. The youth of course. But maybe what really bothers you, is the inevitable fact that you're losing your skills, charms, looks and vitality. Quick, buy a sports-car or do a parachute jump while you still can.

- Aged 70+: the "wise mummy" ages
You had the privilege to reach this age, and hopefully you can watch over your little empire of ((great)grand)children. You're anything except like a teenager, apart from the fact you got stubborn again; people won't teach you or tell you what to do anymore. Been there, done that.

I'm quite good in making things sound a bit more dramatic than they actually are. But honestly, I'm a happy man blessed with friends, family, a good looking & caring woman, a healthy kid, a house, a job I don't mind doing extra hours for, and an environment that doesn't explode like you see on the news channels. It could have been a thousand times worse. I'm not a believer, but I should thank God anyway.

It's just that I'm aware that things won't get much better than this anymore. There is a difference between evolution and revolution. From now on, things evaluate, hopefully with a positive trend. But you can't get drunk for the first time anymore, or feel the same sick making love you experienced your girl X years ago. Your next house will be a step forward, but you already know how to wash your own underpants. And worst of all, a new video game under the Christmas tree won’t get you over-excited anymore…

Off topic, Julio made a poster we'll be putting on a nearby school (hopefully) soon. Let's see if we can catch a few talented students with that! Oh, and if you guys like this poster, I can post or send you a big-resolution version as well.

The "Getting older" ages
Speaking of games... Every boy born after 1980 has a list of favorite games. We grew up with Nintendo's, Sega's, Playstations, Amiga's or the PC otherwise. And if you don't have a list of favs because you dislike gaming, you’re probably not reading this anyway. Shoo! I make an exception for girls, as they may found serenity with games somewhat later in the timeline. Girls + games = not cool, at least that is a label designed by women themselves. But it seems more and more girls set aside their image and just learned to enjoy games. Unfortunately my girl missed the boat, but damn sure I will play Double Dragon with little Julia as soon she is ready! Her hands aren't big enough to hold a controller so far, but time and vegetables will heal that.

As explained, my listing of favorite games doesn't grow much anymore now that I reached an age we would call “grandpa” in the past. Though I was pleasantly surprised with the brilliant "Advance Wars" (GBA / NDS) series and Red Dead Redemption not long ago. But all in all, the lack of time and age are making it hard to get truly charmed by a game. When picking up a new Zelda for example, I can't help but thinking I've seen the same puzzles, items, characters, worlds, music and ideas (too) many times before. Stories change, but the core is still equal to the SNES and N64 versions I first played. GTA V was fun, but I naturally started comparing it with "San Andreas" (one of my favs), and concluded I'm not getting transformed in a wigger anymore, listening to nineties ghetto rap and spending the evenings with my little brother on the attic playing this game. The impact was much smaller.
Nostalgia is something you can't buy.

And there is (the lack of) time. During days, I can't play violent stuff with kids around. During the evenings, my girl steals the TV for Polish soaps and other excrement. During the nights, well, either I program or sleep then. So what happens with long and complex games such as GTA or Zelda, is that they get fragmented in small bits over week or months. Sounds more durable than paying 50$ and finishing the game two days later after 48 hours non-stop action. But with such random intervals, you continuously forget the story plot, what you were doing, and you won’t get "sucked in". I still play games, don't get me wrong, but usually I pick the older ones that are easy to boot up, play for 30 minutes, save & shut again. Like eating fastfood instead of reserving a whole evening in a star restaurant.

Last but not least, there is no-one to share the experience with. As a kid, you'll draw Yoshi with your classmates. Friends came over to see Command & Conquer on your brand new turbo Hertz 486 PC, and also on a later age, we used to play games like Resident Evil together, making jokes about zombies, ridiculizing the plot (and play tough to mask our fears). But those persons are gone, gave up gaming, or can’t join you on a regular interval anymore. My big girl doesn't like games, little girl is still too young, brother doesn't live in the same house anymore, and friends are busy as well. All the hope is on my daughter. But until then, let's try to keep the vibe by at least not forgetting all the good times we had in the past.

"That little guy almost moves like a real human!" my father said, astonished.

All-time-favorite Post Mortem Reviews
In the next months (or years?), I'd like to commit some topics on my all-time-favorite games. I know this blog should be about T22, and there are plenty of (classic)game websites already. Then again, there is less to post about T22 because either I already told you about it, and in some stadiums there is just not that much to share. Either the progress is slow, the content not very interesting, or the new work is classified "top secret". But moreover, in my case games influenced my "Magic" and "Experience" ages quite a lot, and that experience is also applied on Tower22. I didn't study programming to make boring databases obviously!

Besides, I always wanted to write a game review, so why not? Long before the stupid idea of becoming a "game programmer" settled in my head, I wanted to become a reviewer for a games-magazine. Hence, even now I still review games in my head when cycling to work. What else to think of those thirty minutes every day? So, just for the sake of finally executing this little-boys-fantasy, let me have it my way. Pleeeaase??

Good. To make the (post)reviews slightly different than the billion others out there, I'll try to give them a slight game-design twist, as I always looked very critically to games. I didn't just play & enjoy them, I saw them as competitors (imagining I'd be making my own games) and analyzed the good, bad and ugly of games. Though I missed most of the very early game stations (Commodore, Atari, NES), I also saw the evolution of games. Or revolution, when comparing the technical leaps between Tetris, Wolfenstein and Crysis. Sure, games and hardware still march forward these days, but not as spectacular as they did in the nineties and early 21th century. Man, I played “Air Borne Rangers” on a PC without a harddrive, California Games on a monochrome (green - black) screen, and stared with open mouth to the super smooth animations of Prince of Persia, which was displayed in a shop window somewhere during a cold Christmas in 1990.

8 bit eye-opener
Well, I won't review anything in this topic yet, but I'll finish further with my own history in games. Our first computer, a XT-something, arrived when I was six. Ironically, my father didn't know shit about computers yes, so my mother gave the great advice of buying a system without a hard-drive. Everything was on floppies anyway she said. Mom did a typing course somewhere in my Dark shit Ages, so she had all the experience. Well, the roles quickly changed, as mom never used a computer until recently (internet shopping, of course), and dad found a new hobby in it. I didn't -and still don't- understand what dad was screwing in the BIOS and such, but it sure looked interesting. The seeds of "doing something with computers for a profession" were planted.

However, this piece of hardware wasn't used as a game-computer yet. My interest was still in physical toys such as Lego or Minitrix trains. Hence, I barely knew you could play games on a computer. We used the XT for typing crazy commands, and learning what a computer IS basically. No, my eyes really opened one or two years later, when coffee-visiting a girlfriend of mom. Her daughter (what did I say about girls & games?!) was playing Super Mario Bros. On a Nintendo 8 bit. I remember seeing commercials of Zelda (had nightmares about a lion and a sleeping princess for some reason), but I never saw a Nintendo in action. Nor did I heard of the "Platform game" concept. It was totally new, and man... it was awesome. Everything about it. The colors on the TV, jumping a fat little red guy, the joysticks, the orange Zapper gun. As soon as we got home, I started to make my own Nintendo... made of the Minitrix train box with a transparent front, and a drawing of the 2D Mushroom Kingdom that could roll by inside this "TV". Making a jumping character turned out to be too difficult for this little boy though.

You can guess what “Sinterklaas” (our version of Santaclaus) red on my wish-list. Unfortunately, the finances didn't allow Sinterklaas to buy me a NES, nor the Sega equivalent. Strange enough that some other friends actually did get a NES. Sinterklaas can't love every kid equally of course. Anyhow, I picked up more and more bits of this thing called "games". I bought Nintendo magazines, and father also figured out how to play games (from diskette or Floppy) on our already dating XT computer. This is how we met California games, Jungle Book, Pac-Man, and Air Borne Rangers. Yet, those games didn't match what I saw the girl doing on the Television with Super Mario. Nintendo was the shit, and every kid in the street had one. Except us of course. History would repeat with Doom2 btw, when I had to wait more than a year before the PC was finally upgraded.

We did borrow a Nintendo for a week one time. Younger ones may not remember, but back in our days there were stores where you could borrow VHS (movies), games or even game-consoles for some days. So I finally had my temporary Nintendo, with the even more awesome Super Mario Bros 3, and some kids in the street also gave my some games to try. Still remember how "Boom Boom" flew out of the screen and didn't return, a classic SM3 glitch. Mom must have observed closely what happened to her son, before getting one of those addictive things in house.

Super Buy
To help Sinterklaas a bit, I started to collect "5 gulden" (~2$) coins that year. And hindsight, it was probably a good thing to skip the NES, because the commercials started bombarding us with the Super Nintendo (SNES), Super Mario World, and Super Street Fighter. Believe it or not, but we recorded these commercials on VHS so we could watch the movie of Mario passing those super sized ceiling-drills over and over again. Those gamepads had 4 colored buttons instead of the 2 red buttons on the NES! Imagine what you could do with that! My little brother and I were sick of jealousy when a woman had to pick prizes in "Wheel of fortune", and chose a SNES. Not for her, but for her nephews. Fuck, why didn't we have an aunt giving us a Super Nintendo? The world can be so unfair.

Forget all other toys. This box and its large grey "cassettes" stood for endless fun. Those who waited for a SNES, probably still get tinkles when seeing this.

But, after collecting coins and saving all birthday money for a year or so, Sinterklaas came again. In the early morning of 5 December 1992, a big box was waiting on the chair. Finally! A Super-... box of electrical heated mattress sheets?!?! What the hell did Sinterklaas do?! That kids, is how my mom made a priceless photo of her 8 year old son almost dying of misery that morning. Mom and dad had electrical mattress sheets, and I remember once saying I would like to have one too. I unpacked the few other small packages, but obviously this Sinterklaas-party was ruined.

"Did you already open the box, Rick", mom asked? No, of course not. But ok, I'll do... and then the 4 shiny red-green-yellow-blue buttons of a SNES gamepad showed up behind the cardboard. The bastards just packed the SNES + Super Mario World in an their old box. The next photo in the album shows a happy 8 year old. Now I played with power, super-power. And then the photo album ended because their son wasted the next 20 years behind a computer. Thinking about it, I wonder if I can ever make Julia THAT happy with a present. The little girl already has everything. I know, don't spoil your kids, but yet it happens.

All right, with that piece of history explained, it's obvious that I'm a "Nintendo" guy. Not a surprise that quite some games in my favorites-listing come from Nintendo. But not much later, the PC got a more prominent role in our house as well. It still took a while before the harddisc-less XT was replaced with a 286, but certainly when the holy CD-ROM came, the PC proved to be more than just a spreadsheet machine for nerds. I'll sure fall back to more exciting PC hardware stories in the upcoming reviews, but let's end this post with my global computer-timeline:

And as the games I'd like to write about somewhere in the next months/year, here my top 10 favorites plus a few more that are worth noticing. Note these aren't the releases dates, but when I approximately met these games

Saturday, February 8, 2014

Light-shafts, take #3

Wasted another weekend on bloody light-shafts, aka volumetric lighting, aka volumetric fog, aka fake shit to pimp your scene. These effects have been in the engine for ages, but when it comes to graphics-programming, your code is always out-dated. Especially when you left it unfinished (and you know finishing things 101% in the programming world is near to impossible). Some pesky little errors remained, you were too lazy to fix them, and one year later you have no clue what is going on so you'll decide to just redo the whole dang thing.

This doesn't look too complicated, yet it's pretty hard to to draw a volumetric beam if you don't have any polygons that catch light.

Anyway. What's up with volumetric-stuff then? For those who don't know, even though we have 3D games for two decades now, we still suck at rendering *everything* in true 3D. Solid walls or octopus monsters no problem. Fine-particle-based things on the other hand... dust, clouds, farts, fog, mustard gas, smoke, you name it. The problem is that you can't really model those things. Unless your artists are willing to make micro/nano sized particle clouds, and your computer willing to handle huge quantities of tiny “points” in a physical correct way. Nope, the level of detail is way too big, so we fall back on simple hacks to fake such phenomena.

For example, if you look at a lantern during night, you probably see a halo around the lamp. Especially if it's foggy or rainy. God didn't place billboard sprites on street lanterns though. It’s just physics minding its own business. Light rays collide with (water) particles in the air, water breaks (refracts) the light, and you see halo's or even rainbows. If you took attention at physics class, it's not all that hard to understand. But teaching your computer correct physics... There is simply not enough firepower to render on such a fine detail, store all that info, or treat light as rays in general. So instead, we just draw a transparent halo texture and put it around a light. Fixed.

As I'm getting a bit older, I learned not to always pick the hardest and most ambitious paths. If it works, it works. Clients usually don't care how brilliant your code is, and in the end most stuff you see is getting more and more fake anyway. Movie actors spend more time in front of a green screens instead of making an actual stage, soon my 5 year old daughter will Photoshop herself to a 18 year old supermodel on Facebook, mcDonalds meat isn't really meat, and I learned the dinosaurs in Jurassic Park weren't actually real either. And game-graphics are everything except a correct physics lesson.

Some effects can be simulates pretty easy. Others are more complicated. Most modern games have scenes where the sun casts beams through a forest-roof, or where dust appears behind a window as light falls in. Hence that already happened in N64 games probably. Of course they didn't actually render microscopic dust particles. The 3D artist just made a transparent box-shaped volume behind a window. That trick wouldn't work well for a forest though, as you would need to model dozens and dozens of leave shaped "pipes" in your scene. And if the sun moves, all those pipes had to be adjusted as well.

Luckily we found yet another cheap trick to fix that. Wouldn't run on a N64, but a somewhat modern computer should handle it with ease. The idea is to render the sun and maybe a darkened version of the skybox into a (small) texture. Then next step is to draw a screen-filling quad, where each pixel fires a ray towards the sun (it's 2D screen coordinate). For each step towards the lightsource, accumulate the color from the texture made in the first step. Basically it's a reversed way of smearing out blur streaks from a bright spot on your 2D canvas. More details:
Volumetric light as post effect, nVidia GPU Gems 3

Works well for one or a few dominant lights in the background. Doesn't work too well if the lightsource isn't visible directly. Huh? If you walk through a corridor, you might see sunlight falling through the windows, but without seeing the actual sun itself. As soon as the lightsource gets occluded or when you turn your back to it, it won’t get rendered on the input-texture. Thus there is nothing to blur / smear out, and this no lightshafts either. For example, it wouldn’t work for the scene in the picture at the top of this article; the viewer can see the light beam, but not the light that casts it.

To fix that, yet another trick came by. Nothing new either, although games may still not use it on a wide scale because it's a beefy effect. The idea is that for each pixel on the screen, or at least for each pixel that overlaps a light volume, you send a ray forwards. This ray might intersect the light-volume at some point. If it does, you accumulate a color. To make the effect more impressive, you can test whether that particular point in space wouldn't be shaded by using a shadowMap. This is obviously the more advanced effect, but it takes a lot of sampling, and requires a shadowMap to become really cool.

A basic explanation. It seems more advanced, optimized versions (less sampling) have been made in the meanwhile by smart guys. I didn't read it yet myself, but:
Intel GTD Light Scattering

Well, problem solved, didn't we? Hmmm. I thought so a few years ago when making these effects for the first time, but I always had problems with performance and flexibility. In my screenshots, such effects usually look quite nice. But in reality, when moving around in the scene, the effect could become barely visible or way too visible. Since it's hard to predict how many samples will accumulate light for a certain point of view, the results can vary quite a lot. After some shader- tweaking it would usually look better, but blow up again in a different scene one month later. Or adjustable parameters were hard to understand and still didn't achieve the desired results.

On the bottom-left buffer it seems pretty cool. But in-game it looks as if a honey-bear took a dump in the chandelier. Balancing problem.

Maybe the real problem is that the techniques above are fakes that can only cover one particular effect. Whether to use them or not really depends on the situation. For example, the effect above works for making a color or dust particles INSIDE a lightbeam visible. But in my dusty T22 corridors, I basically need dust everywhere, thus also in area's that aren't directly lit. I would need to complement the effect described above with another one. For example by filling the whole area with dust-sprites that slowly fly around.

The point is, each situation differs and asks for different techniques. Sometimes advanced shaders, sometimes cheap tricks that your grandpa invented already. Being ambitious (and younger), I tried to make a single multi-functional shaders that would solve all my "volumetric needs", but that didn't work out. Way too much overhead, too little artistic control, and tweaking it was like Jenga. Insert a block to improve effect A, and it will screw up effect B as another block falls out on the other side. So, I decided to disassemble again into multiple, simpler effects again. Let the artist decide what is needed for scenario X. It feels a bit unnatural though. Game engines try to solve more and more graphical issues with realtime, dynamic, uniform "super-shaders" rather than giving a bunch of dirty tricks.

I wonder how modern engines like UDK or CryEngine deal with this. Does the artist just click a button to get instant-awesomeness (whether that is a volumetric fog field, nice lighting & G.I., or a reflective flooded scene), or does it also involve a lot of parameter tweaking, masking ugly corners, and messing around with multiple techniques to see what works best? It's easy to get fooled by screenshots or carefully scripted movies. Like I said, I've become Goebbels when it becomes to showing you the better looking parts of the game. And so are they.

Well, after the latest adjustments, I should be happy again with the volumetric effects for about 3 months. Then I probably get jealous again after seeing a picture or game that seems to do it in a better or smarter way. The graphics-programming lifecycle in a nutshell.