July 26, 2006

Shader Instancing

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)

- One comment Not publicly viewable

  1. M Clark

    Those are the lost numbers, no?

    29 Dec 2006, 22:45

Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

July 2006

Mo Tu We Th Fr Sa Su
Jun |  Today  | Aug
               1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Search this blog



Most recent comments

  • I hope progress is being made, I would pay £30 for this game in 3d, I have many years enjoyment from… by AndyC on this entry
  • Well, I'd love to carry on working with it and I suspect I'll try and at least clean up the code and… by on this entry
  • Nice 3YP – a friend and me tried a similar project a while back – your videos of 3d rendered green l… by Cyphus on this entry
  • Also I checked, the presentations are open to anyone that wants to go, Computer Science or otherwise… by on this entry
  • My presentation is CS1.07, the full list is available here (proxy/campus required). by on this entry

Blog archive

Not signed in
Sign in

Powered by BlogBuilder