Tuesday 25 May 2010

Gamma

Yesterday's post about sound reminded me of the problems I had with gamma correction. Getting on for a year ago I decided to create all the menus. Mainly so I didn't leave it to the end and rush them.

I am glad I did because there is a lot of fiddling about to create each screen. Nothing difficult but still time consuming.

I created a screen to adjust the volume levels of the music and effects separately. The levels are easy to impliment using XACT but the form took a while to get all the sliders drawn and working.

Anyone who has done any windows programming will be used to having a whole host of controls to just drag and drop on to a form. Then you write the code behind it. In game development targeted at anything other than Windows you need to create all the controls you want to use yourself.



In the above form you'll note a rather wordy description of how to adjust the contrast and brightness. This manual solution was the end result of spending ages trying to find a way to set the gamma levels on a graphics card.

I eventually failed. On all the PC's I tried changes to the gamma settings resulted in nothing at all happening. When I tried this same code on an Xbox I got a black screen.

My alternate to the manual solution would be code all my shaders to include an adjustment to the lighting value. I have decided that there are many other areas of the game far more important and as yet I have not seen an Indie game solve this, so I am at least no worse than others.

I will probably simply remove the note and the contrast bar from the finished game.

Monday 24 May 2010

Sounds

I got side tracked again. I was bored play testing in silence so I have added gun shot sounds. I already had music for the menus and a click for menu choices, so I was not starting from scratch.

Basic sounds fitted in nicely. I already had enough code to display a decal when the round hits a structure. That same code path was perfect for putting in the play command for a sound and storing what sound each round made, both at the muzzle and upon impact of an object.

The problems came when making them 3D! Sounds further away need to sound quieter. There is an Apply3D method but to go with it I had to learn how to set this up in XACT. Not as difficult as I thought, but getting it right for my scale, 1 unit = 1m, took some tweeking.

The other problem I have is that for some reason the 3D sounds don't work on my main development PC but are clearly audible on the 360 and on my secondary PC. Odd but it just means I have to test more frequently on the Xbox.

The bit I don't like is that XACT still creates a tiny bit of garbage. I'd avoided the obvious areas but eventually after lots of searches on forums decided the last bit of garbage is unavoidable. Garbage is any object that uses memory on the heap and then needs disposing of during the game. It can interrupt game play. My aim is to avoid any garbage collection during a normal game. My target is 10 minutes between garbage collections.

At the moment I am well within target so I've added sound to my list of areas that create some garbage. It's a short list because the only other thing on it is particle emitters. I'm sure I'll come back to that when I decide I must reduce garbage further.

Back to animating my alien character.