Blog 2.0
Dark Style Medium Style Light Style

Blog Statistics
First Previous Homepage Next Latest
RSS Feed

Virtual Textures

Recently, I began considering how I would go about rendering the planet in Myriad. I want a large (although not full planetary scale) planet, with a good looking texture spread across it - one thing that really annoys me about landscapes in games is repeating textures so I'd like to avoid that. Also, I want to be able to paint decals on the landscape.

I thought about this for a while and I stumbled across megatextures (John Carmack, ID software) and sparse virtual textures, both of which are the same thing (mostly). The idea here is that rather than taking a small texture and painting it across the planet multiple times, we have a single massive texture and only load into graphics memory what is actually needed on screen.

So that's rather cool, using this technique we're basically unlimited by how big the textures can be, the main problem is going to be storing them on hard drive! This means no repeating of textures at all, and the texture can be modified for unique decals painted onto the landscape with almost no extra overhead.

How does it work? Well it's really rather simple, first of all we need somewhere to put the loaded data, so we have a large texture which I call the DataTable, this datatable is about 2-3 times the size of the screen (which may sound large, but we can load all texture data into here and the amount of video memory used never changes. This data table is divided (in your head) into pages, I'm using 32 or 64 square pages. Texture data is loaded into the DataTable texture pages at a time, pages have no relationship at all to the adjacent pages, they're laid out randomly. How to access this data? Well that's really rather simple too, another texture is created which I call the IndirectionTable, this table has one texel for every page in the DataTable, this texel contains an offset and a scaling factor - now to read texture data you simply sample the indirection texture using your normal texture coordinates, this will retrieve the offset and scaling factor for you to modify texture coordinates by to find the appropriate pages in the data table, which is then sampled and returned. So, simply using 2 texture reads and a little bit of maths, we can support textures up to any size, with a low memory overhead.

What're the downsides? Well obviously maintaining the data in the data table has an associated CPU overhead, and streaming all that data from system memory to video memory will consume precious bandwidth, which may or may not be a problem.

Posted on 2009-09-02 09:11:37.076017
This post : 239 views
Permalink: http://martindevans.appspot.com/blog/perma?agxtYXJ0aW5kZXZhbnNyEAsSCEJsb2dQb3N0GLHqAQw

Author:
Post:

Thankyou Petri :)
I wonder if I should start publishing my blog posts in Ziggyware (when they're XNA specific)?

written by Martin , on the 2009-09-13 01:06:27.944424

Hey, nice ideas here :)

written by Petri Wilhelmsen aka DigitalErr0r , on the 2009-09-07 22:49:22.987176

Incredible someone actually commented on my blog! ;)

Unfortunately it's turning out to be rather hard to implement, but that's mostly because I've never really done anything like this before!

written by Martin , on the 2009-09-04 01:15:56.887539

Bravo, what the right words ... great idea

written by NetNuggets , on the 2009-09-03 01:35:12.659567
Latest Entries:

Triangulation and Blog 2.1
2009-11-09 18:03:49.415016
Neglect
2009-11-05 21:54:34.749240
N
2009-09-13 01:55:27.993530
Virtual Textures
2009-09-02 09:11:37.076017
Hard working Laziness
2009-08-19 14:11:45.639809
Don't go into the long grass
2009-08-03 17:49:34.315912
Oops!
2009-07-08 00:56:45.557563
Landscaping
2009-07-01 12:06:04.994983
Web Development & Game Development
2009-06-18 18:27:18.057752
Furry Rendering
2009-06-10 20:02:15.395323