Monday, May 31, 2010

Secret Progress

The secret project, codename Dreadnaught, is proceeding rapidly.

The menu is working; including the switch to the combat test.
The combat screen is rendering, but without textures or lighting.

I am now working on movement, acceleration, rotation and collisions.

I will post screenshots and an explanation of the game when I have more to show.

Wednesday, May 26, 2010

It's quiet. Too quiet.

Yes, I haven't posted anything since early April. The reasons are many, but unimportant.

The last few weeks I have been working on a much simpler game, in secret.

I got a big breakthrough in my work on OpenGL GUI components by reading an article or two about premultiplied alpha in textures.

The name 'premultiplied alpha' originally caused me to think 'Why would you want that?' When I discovered what it really meant, it became clear that I was thinking inside the box. Inside this box the name makes sense, but the concept seems useless. Here is the way out of the box:

Premultiplied alpha is actually a method to separate light that an object adds to the image from light removed by that object from the image. For instance, an opaque green object on a red background adds green light and removes the light from behind it, while a green flame would add green light without taking away any, and a transparent black object adds no light but takes away a portion of the background light. So now you can have all of these on the same texture, rendered simultaneously. Before, you would need to render them in separate passes and with different blending modes, easily doubling the amount of processing done.

Some more advantages are that textures with premultiplied alpha work well for stretching/shrinking the texture, for anisotropic filtering, and for DXT compression.

How it works is, the red, green and blue components of the texture only contains the amount of light added by the texture, and the alpha only contains the proportion of the background light to remove. So, for a non-glowing transparent object, it would be exactly like the normal texture, except that the added light is premultiplied by the alpha, and from there the name.

To render my GUI correctly, I no longer need to align the GUI elements' texels to the pixels, and it also does not matter if they stretch a bit, so I could greatly simplify the code. I have working buttons and images now.

I can now also scale in-game objects arbitrarily, and lighting is simpler than ever. I might not even need any shader programs at all this time.

Keyboard setup is working well, but I need to update my text renderer to use premultiplied alpha and fit in with the GUI components before I can make it possible to set it up from within the game.