Wednesday, July 16, 2008

To shade or not to shade

As we ramble on towards a demo, we've just switched a gear, okay a few gears, so we can make an internal deadline in time.

The latest build of the game has been stripped of all the shader functionality. For those who aren't familiar with the term, a shader is a program that is compiled and run on the GPU. They have local access to textures and object data, hence making rendering much, much faster than using a software-based renderer.

The shader sub-system that we had written into the game was behaving weirdly. Our in-game editors kept crashing for no apparent reason, and some scenes showed too much lag - something we'd need to address. But knowing that fancy eye-candy isn't on the main todo list, for the upcoming demo atleast, its kinda been kept aside for a bit.

Some bugs have been ironed out though, and there are some screens that we do wish everyone could see. A few screens first, then some explanations...















The above screens show a fur-shader in action. Agreed, the chimera was meant to be a reptilian thing, and reptiles don't really have fur, but hey, it looks nice, doesn't it?

The fur-renderer that I had written into the game build worked pretty nicely. However, the algorithm used needed 6 render-passes - that means each triangle in the above model was drawn 6 times (after depth-testing). This effect is only possible with programmable hardware - and is achieved using shaders in OpenGL. The 6 render passes kills framerates on older hardware, meaning you'd need atleast 256 MB VRAM and a pretty recent GPU, to actually get it to look good at decent frame rates.

Now, though, for the oncoming demo, the shader framework will most likely be out. Do keep your fingers crossed though...

So much for a first glimpse at shaders in the game.

Thursday, June 12, 2008

Of art pipelines and other stuff

Well, today I finally got around to testing the new collision-detection scheme in the game. I've got a new system into the engine, based on the popular, yet lightweight, collision detection library - OPCODE (http://www.codercorner.com/Opcode.htm)

This has some far reaching consequences. Firstly, OPCODE is a highly optimized library. That means our current collision scheme will be matched in terms of speed and far surpassed in terms of accuracy (initially, we were dealing with bounding-boxes). Secondly, as a result of this, we're now going to have a much better art pipeline... confused? read on...

One of the many quirks on my mind about the Top Secret: CNGH project was how we'd get those fantastic town/ race-track designs into our game. The primary problem is that the community which designed these layouts didn't have to worry about the implementations. When it came to us, I was initially very happy to just get bounding-box queries done and put in blocky models, mostly made with some CSG tool like WorldCraft. For those of you who don't know what CSG is, it stands for Constructive Solid Geometry. It doesn't work like your standard 3D meshes. Instead it is composed only of primitives (and some recent additions allow for some variations - patches, bezier curves etc.). That means that the collision detection becomes very easy - instead of querying against randomly oriented triangles, you can construct a tree and perform calculations very easily. One of these trees is called a Binary Space Partition Tree (or BSP). Now I don't want to get into the details, but this idea was (and is) very popular with "dungeon-crawling-corridor-sprawling" FPSes (Quake and Doom). In fact, even Half-Life used a proprietary BSP format.

Now, imagine taking primitives and making a believable town/ race track out of it. Imagine yourself, sitting with primitives (cubes/ cuboids/ cylinders for the most part) and building up organic caves... not a very good idea. With the introduction of OPCODE into our engine, we now have polygon-to-polygon collision and that means we can now make our models in standard modeling packages like Blender, and use 'em to great effect, without having to worry about performance issues.

Well, thats it for a start. Expect more stuff very soon. If you're the impatient type, there are some cool screens coming up as well... ;)