Friday, January 9, 2009

More HLSL Thoughts

Since I wrote that last post I've been thinking more and experimenting more with the whole HLSL thing. There are at least a few areas where - even in a stock Quake renderer - use of a shading language makes perfect sense:

  • Water warp updates. I'm now satisfied that render to texture is a non-runner for this owing to Video RAM and speed considerations. A pixel shader could do the job just as well (in fact it was effectively a software pixel shader in the original Quake).
  • Underwater warp - ditto.
  • Fullbrights. Getting the correct formula ((lightmap + fullbright) * texture) is messy with fixed functionality. Texture stage states are fine enough but there's too much setup and takedown involved to make them realistic for all of the special-purpose situations Quake needs.
  • Matrix transforms. A lot of Quake content needs to go through a number of matrix transforms, meaning that either you can't batch the renderer properly or you do it in software. Here's where a vertex shader could make things so much easier.
I'm certain that there are others, but these are the primary ones that are annoying me at the moment.

Anyway, I've just written the first on the list, replicating the old software Quake warp as closely as possible, and not only does it avoid the video RAM overhead of render to texture, but it's about 1.5 times faster and looks a lot better. It also means that liquid surfs can now go into a proper vertex buffer rather than needing to come from main memory, so there will be more performance gain.

This is a point of no return; HLSL is definitely on the menu now. It's solved one major stumbling point I've been unhappy about and it's all been gain.

Unfortunately what this means is that people who don't have a pixel shaders 2.0 card are going to be locked out from this point forward. Sorry about that but I suppose it's progress. The alternative is that I get totally bogged down in trying to build backwards compatible solutions within the limitations of finite resources, meaning everyone would lose.

0 comments: