Thursday, July 15, 2010

Bounds, Fragments and Updated tools

Progress has been slow with my virtual texture experiments because I've come to a point where I can't simply work on things iteratively and need big chunks of time to work on some things.

I've managed to do some things however.

The first thing I did was rewrite the whole layout of my virtual texture file & the way they are loaded so that page definitions are separated from the texture pieces (which I named fragments) that form them.

This will make it possible to eventually support things like procedural and dynamic textures.
It will also allow me to share fragments between pages, which for the time being, speeds up my virtual page generation a lot, which is useful when I need to make more modifications in the future.
It also made it possible to define that a page consists out of more than just a diffuse layer, and my virtual texture file now also contains normal and specular maps, although I don't actually use them yet.

Another thing I've done is calculate the bounds of each page, by clipping the pages' geometry by the page boundaries, and then calculating it's extends.

Here you can see the bounds being rendered around their pages.
It shows how doom 3's texture usage is horrible for virtual texturing, and I really should be merging geometry and projecting the textures onto it.
But not now, because it's a nice worst case situation for testing.

What I really want to do first is start ordering pages in the virtual texture by how close they are together in worldspace, and I want to try to see how better or worse an analytical solution to page visibility would perform.

But before I can do that, I need to implement VSD.
Right now I'm rendering the entire level each frame, but I really should be using doom 3's portal/area information to do some simple portal rendering instead.

Another thing I should be doing is to do the page assignments in the virtual texture on a per area basis, because this will improve page locality at lower resolution mip map levels.
Right now a page on one end of the level could sit right next to a page on the other end of the level.

At a lower resolution mip level, the two page bounds would be combined and the bounds would enclose the entire level.
This is obviously bad because the bounds would become increasingly unusable at lower resolution mips, but it also makes us load a page where it's parts will never be used at the same time.