November 30, 2009

Lightmaps and Vertex Buffer Objects

I spent some time familiarising myself a bit more with multipass rendering. I set up a very simple test application where I could do live editing of the major settings and see the effect.

This had a quick win: I figured out that my equation for blending in the lightmaps was wrong. The screenshot above shows the right settings (with the top for the base texture, and the bottom for the lightmap). The screenshot below shows the result when applied to a Quake level.

The scene is much more vibrant now. I think this is how it should have looked from the start. But it's hard to find this kind of information online. It really takes some experimenting to figure it out.

I also put some work in improving the performance. I figured that switching from vertex arrays to vertex buffer objects should be a smart thing to do. This way I could upload the scene data to the graphics card just once, and reuse it as needed. No more continuous streaming of vertex array data. Everything is reduced to a bound id and an offset.

The result isn't bad: an increase in fps of about 50%. So where I got 100fps before, now I see 150fps. In some locations that goes up to about 200fps.

Next I should really do some cleanup of my code. All the hacking and experimenting has degraded the quality somewhat.

3 comments:

Crimson13 said...

Nice results. Certipost not keeping you busy enough? :-)

Kris said...

Plenty of work at Certipost. But the BSP stuff is just relaxing after work. No application servers and Enterprise Java to deal with when doing that. :-)

I recently described JEE development as "walking a tightrope". It's a lot better than five years back, when you couldn't write five lines of code without one of them being XML. But it's still a lot worse than other approaches (e.g. Ruby on Rails).

But I'll cope. :-)

PS. Looking forward to the point when I'll be able to include animated MD2 models (thanks to code by a certain Crimson13) in the BSP levels.

Crimson13 said...

Ah, the golden days of Lamarone :-)