Poor man z-sorting

Those of you who still watch sandy engine, know that there is pending maintenance release with almost no new features (unless they finally backport MD2+MD3 support from haXe branch). However, sometimes new features do get added; for example… BSP sorting in single container mode.

Ever since Thomas added Renderer class a year ago it was possible to implement dynamic BSP sorting for whole scene (just like Infinity3D did), but noone working on sandy seem to have time or skills, and this never happened. On the other hand, an opportunity to implement simpler static BSP sorting existed ever since single container mode was introduced (which was, I believe, well over two years ago). As some people noticed, I did just that this weekend, in a matter of hours. Check it out – here. On the left, you can see good old average Z sorting, on the right – BSP. Well, if that was so easy, why noone did it for “over two years”, huh?

Of course. There is a catch. This code does not modify geometry at all, no polygons are split and no complicated geometry analysis is done. Why? Simply because sandy is not friendly enough to do this within maintenace relese. You might remember that sandy was first 3D engine to implement frustum clipping; this algorithm already provides us with all the means to split face by plane (remember this), but you can store just one result of this operation per face (when we need many of them obviously) or, alternatively, you have to modify underlying geometry itself. The latter option would not be that bad, if not for the magnitude of hack it takes to get it done. I tried it last January and gave up on that, but for the purpose of this post I have done this PoC. Just so you know that I am not talking entirely out of my ass.

Okay, so here comes the million dollars question: who the hell needs BSP that does not split polygons? I don’t know, probably poor people with no cash for Alternativa3D license :) It is true that new BSP sorting mode will not display your model correctly, unless it is carefully designed to work in this mode. It is exactly the same way it was before, when you had to carefully design your models to work in average Z sorting mode. In this demo above, click anywhere to display models “optimized” for corresponding sorting modes, to see what am I talking about. On the bright side, BSP feature will be open for scripting, so that anyone can write BSP importer from GtkRadiant, or clever Blender script to help modellers.

Ask a Question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Old stuff

October 2009
« Sep   Nov »

Oh, btw…

%d bloggers like this: