Last weekend I spend a little more time on my VT experiment and added normal, specular and alpha channels to pages, all of which area only stored when they're actually used. I've also added alpha testing support, since id tech 4 makes heavy use of it, which made me split the geometry into two stages. I'm not entirely sure if it's a good idea to support alpha testing in a real world virtual texturing engine (especially when an engine is using deferred rendering), so I might remove it eventually.
My short term goal is to render this into a G-buffer and do some simple deferred rendering (just a naive, simple deferred rendering implementation will do for the time being).
I've also spend some time optimizing my import pipeline, and each stage (a separate executable) only takes about a minute (at most) except the stage that creates the virtual texture itself. That final stage doesn't scale very well and it can go from a minute to 30 minutes depending on the size of the virtual texture. This is mostly because of the part that creates the mipmaps for each page, this is mostly because I'm not using simple box filtering but using some more better quality solutions instead.
I'm considering just using pre-mipped source textures for this since it would bring back the vt creation time to basically the time it take to write it to disk, but it would snap all my pages to 128x128 coordinates, which could create a lot of additional wasted texels in the worst case.. It would also be a temporary solution since eventually I want to re-parameterize the geometry and render the textures into this newly created texture space. It won't allow me to re-use as many pages as I am now (which makes it possible to store a 6gb virtual texture in 500mb, uncompressed) but it causes less wasted texel space, simplify geometry and most importantly help with page locality (fewer pages visible at the same time), which would help latency wise.
Monday, February 14, 2011
Tuesday, February 1, 2011
Infinite virtual textures
Labels:
Virtual-Texture
I've been playing with the thought that the page table of a virtual texture could itself have a higher level indirection table, allowing us to create much bigger virtual textures by dynamically allocating huge virtual texture blocks. This would make geometry streaming simpler with virtual texturing since you wouldn't need to have the entire worlds' page table in memory at once and can help avoid precision issues when page tables get too big.
The texturing on geometry would not be able to cross the edges of these higher level blocks, but that would be fine because the dimensions of these blocks would basically still be really big, much bigger than you'd ever want polygons to be. Also, we only really care about the actual texture pages that we store on disk and loading them quickly enough, if page tables have huge empty spaces, it doesn't matter because they don't actually take any space on disk, or any substantial space in memory. So if we have lots and lots of additional page table space, we gain a lot of freedom in how we built and update our virtual texture, and how we place our model/level textures within our virtual texture. We don't need to pack it as tightly anymore and we could consider using other metrics to place our textures in our virtual texture, for example proximity of the geometry on which the texture lies.
Obviously we do not want to have an extra indirection in our pixel/fragment shaders, which would be terribly wasteful, but we could easily use our vertex shaders for that, considering that geometry wouldn't be allowed to cross these higher level blocks. Another way could be that suppose you can load X page table blocks in memory at the same time, and each page table block would have a fixed position within the page table then you wouldn't have to use a vertex shader either. But you'd have to guarantee that no two page table blocks with the same position would ever be loaded, which might be fine if you have enough block positions.
On another note I've been looking at Assimp (I know what you're thinking, but no, that stands for Open Asset Import Library, you pervert) and it's pretty cool. I couldn't get the .net library to compile, which is a shame, but I've been using the C compiled command line tool to convert all the Lightwave files in quake 4 into an easily parsable XML format, which I then parse and use in my, oh so neglected, virtual texture experiment. It really makes everything feel more like an actual level, instead of random geometry with big gaping holes in it ;) Along the way I discovered that somehow my geometry was swizzled across an axis compared to quake 4, so I fixed that. In the process of getting all the geometry in the level I've had to parse all the skin, guide, mtt (material type), and def (entity definition) files (next to all the mtr (material), map and proc files that already was parsing before), which was a big adventure in figuring our how the id-tech 4 technology worked from a data point of view. Certainly gave me renewed respect for it's flexibility, despite the engine's age.
One of these days I'm going to put support for all the texture and door animations in my little demo (well, it's actually starting to become a little engine of sorts), and put in proper support for texture blending. And brute force page VSD as a pre-process (to determine if a page mip can actually ever be visible). And fast texture compression. And lighting obviously. And physics. And maybe it's not really an engine after all :)
The texturing on geometry would not be able to cross the edges of these higher level blocks, but that would be fine because the dimensions of these blocks would basically still be really big, much bigger than you'd ever want polygons to be. Also, we only really care about the actual texture pages that we store on disk and loading them quickly enough, if page tables have huge empty spaces, it doesn't matter because they don't actually take any space on disk, or any substantial space in memory. So if we have lots and lots of additional page table space, we gain a lot of freedom in how we built and update our virtual texture, and how we place our model/level textures within our virtual texture. We don't need to pack it as tightly anymore and we could consider using other metrics to place our textures in our virtual texture, for example proximity of the geometry on which the texture lies.
Obviously we do not want to have an extra indirection in our pixel/fragment shaders, which would be terribly wasteful, but we could easily use our vertex shaders for that, considering that geometry wouldn't be allowed to cross these higher level blocks. Another way could be that suppose you can load X page table blocks in memory at the same time, and each page table block would have a fixed position within the page table then you wouldn't have to use a vertex shader either. But you'd have to guarantee that no two page table blocks with the same position would ever be loaded, which might be fine if you have enough block positions.
On another note I've been looking at Assimp (I know what you're thinking, but no, that stands for Open Asset Import Library, you pervert) and it's pretty cool. I couldn't get the .net library to compile, which is a shame, but I've been using the C compiled command line tool to convert all the Lightwave files in quake 4 into an easily parsable XML format, which I then parse and use in my, oh so neglected, virtual texture experiment. It really makes everything feel more like an actual level, instead of random geometry with big gaping holes in it ;) Along the way I discovered that somehow my geometry was swizzled across an axis compared to quake 4, so I fixed that. In the process of getting all the geometry in the level I've had to parse all the skin, guide, mtt (material type), and def (entity definition) files (next to all the mtr (material), map and proc files that already was parsing before), which was a big adventure in figuring our how the id-tech 4 technology worked from a data point of view. Certainly gave me renewed respect for it's flexibility, despite the engine's age.
One of these days I'm going to put support for all the texture and door animations in my little demo (well, it's actually starting to become a little engine of sorts), and put in proper support for texture blending. And brute force page VSD as a pre-process (to determine if a page mip can actually ever be visible). And fast texture compression. And lighting obviously. And physics. And maybe it's not really an engine after all :)
Subscribe to:
Posts (Atom)


