All 1 entries tagged Instancing
No other Warwick Blogs use the tag Instancing on entries | View entries tagged Instancing at Technorati | There are no images tagged Instancing on this blog
July 26, 2006
Once again a slightly long than intended break from blogging my progress, but until today there hadn’t really been much. For the last 3-4 days I’ve been researching/investigating a technique called “Instancing”. To put it simply, if you want to draw the same object many times over, you might as well just give the graphics card one copy of the object, and a list of places you want it drawn, rather than lots of copies and lots of locations.
For example, if I wanted someone to go and post 6 newspapers in my road, I probably wouldn’t say:
“Go and post a newspaper to 4 Western Road”
“Go and post a newspaper to 8 Western Road”
“Go and post a newspaper to 15 Western Road”
“Go and post a newspaper to 16 Western Road”
“Go and post a newspaper to 23 Western Road”
“Go and post a newspaper to 42 Western Road”
I’d just be wasting my breath, it could be put a lot simpler:
“Go and post a newspaper to [4, 8, 15, 16, 23, 42] Western Road”
While it doesn’t actually make delivering the newspapers any quicker for the delivery guy, theres less time spent awkwardly listening to me reel off “Go and post a newspaper to x Western Road” 16,000 times…, this is basically what instancing can do for drawing geometry/meshes in 3D graphics.
Theres a few different ways of implementing instancing, which I won’t go into, but suffice to say some are a) faster and b) better supported than others. While it might have made my life (and performance of the game) better if I’d used Hardware Instancing, 80%+ of people reading this probably then wouldn’t be able to play the game. So, I went with Shader Instancing, and it seems to be pretty quick.
To demonstrate, believe it or not, I’ve made a video. The video shows my game running with NVPerfHUD4 running over the top, this gives me lots of information about the graphics card etc etc. It also allows me to step through the individual stages in rendering a single frame of the game.
The map shown is 256 X 256 squares (the size of maps in the original “Transport Tycoon”) and is gradually covered with 65,536 depot/bus stations, one for every square on the map. With every square covered, we’re drawing 2,300,000 polygons per frame, an incredible amount. Had I tried this same test without Shader Instancing you might have mistook the game for a very slow slideshow of still images.
If you couldn’t tell already, I’m pretty pleased with the work involved in getting this done, and it really does mean I can start doing much more impressive things without the framerate taking a huge hit.
I’ve written enough for now, back to work. :)
Download video (Xvid, 11MB)