Wednesday, December 30, 2009

Fun with Water

I think the basics are getting towards being complete now. I've just done water in both HLSL and non-HLSL modes. The non-HLSL mode has been accelerated somewhat as it's possible to draw the entire surf (all subdivisions) with a single call, so low values of gl_subdivide_size should have lessened negative impact on performance. I recommend you start with 24 and only work upwards if you really feel you really need to.

I've decided to tune the triangle list generation a little, so on the first startup DirectQ will examine various properties of your 3D card and make some assumptions, following which it will set the maximum batch size it generates. This will be based on factors such as whether you support pixel shaders, whether you're a hardware T&L device, and how much video RAM you have. It's also clamped to the max batch sizes your card can support. Values I've chosen are purely arbitrary and based on rough guess work rather than anything grounded in reality.

Following that you can always override it and you're overrided value will take precedence. You'll use the r_trilistsize cvar to control this; higher values give larger batches but they might choke cards with low bandwidth; lower values give smaller batches but they won't handle complex scenes as smoothly. The value is approximately equal to the highest number of vertexes DirectQ allows in a single batch. I don't allow values over 65535 because I don't want to mess with supporting both 32 bit and 16 bit indexes right now. To recover the autotuned value set it to -1. You'll need to reload the map after each change, so test a bit first.

Setting it to 1 will revert to Quake's standard behavior which you don't really want to do - even ID1 maps can benefit from better batching. The option is there if you feel that you really need it however.

The real ugliness is yet to come, which is support for alpha surfaces and entities. I've been playing with this on and off, and have a basic framework in place, but overall though it's going to break my carefully put together code a little. It's all for the best though as what will come out of it is a nice generalised and extensible setup.

0 comments: