All entries for July 2006

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)

July 17, 2006


Follow-up to A slight snag… from Transport Tycoon 3D

I posted just a few days ago slightly peeved at myself that I'd made such a rookie mistake with regards to my grid. Well, thankfully the fixes actually took a lot less time than I imagined, and by Saturday morning everything was in working order again with the new "4 squares" rather than two.

So soldiering on with Landscaping, and the GUI window associated with landscaping I did, and it's already looking fairly polished. Users can raise and lower land, and then use the level tool to flatten an area of land to a given height. I won't bore you too much with where the remaining areas are to polish up as they certainly won't be there too much longer.

Something that has worked surprisingly well was the small indicator (in fact, just a white cube) showing which vertex you are currently hovering over… something best demonstrated in a video!

Download video (Xvid, 4.4MB) – Average Quality, Small Filesize
Download video (WMV, 6.4MB) – Average Quality, Larger Filesize

July 14, 2006

A slight snag…

Well, there's no beating about the bush with this one, I've made a bit of a mistake. The problem isn't exactly easy to describe, but the crux of the matter is that 2 triangles per square isn't gonna cut it on the grid, I need to change for 4.

My plan for raising/lowering land (landscaping) was to be able to simply raise a corner, and have the four corresponding tiles (each corner is shared by 4 tiles) have their terrain change appropriately. As link demonstrates, the triangles to the left and right of the raised point are fine, the ones in front and behind are wrong.

So, the change to 4 triangles per grid square has a few of problems associated with it:

a) I need an extra vertex per square (in the middle) to be able to draw my 4 triangles, thus increasing memory requirements.
b) I have to draw twice as many triangles as I'd hoped, hurting performance there.
c) It's going to mean rewriting a substantial portion of the code I've already written, except this time, the rewrite is going to be even more difficult than it was before.

It certainly won't be impossible, and I should be able to have most of it back in order by the end of the weekend, but it's certainly a bit of a setback. On the bright side, once I'm done, I can demonstrate landscaping in a video, something I was about to do before I realised my mistake…

July 12, 2006

New GUI and Assorted Features

New VehicleWindow

Most of the work over the last few days has been on getting a skeleton GUI in place that can help me when I'm trying to work out how different features interact/interfere with each other. For example, if you aren't trying to click a button on a window, you don't also want the click to go "through" and onto the grid behind and build some road.

I also got round to working out how to turn on Mipmapping, which a) makes the grid look 1000 times better, and b) gives about a 6–7 times performance boost, since it's drawing lower resolution textures further away from the camera.

The green car representing, well… every vehicle under the sun will stay for a while longer until I get round to replacing it with something resembling a bus, but it's hardly urgent. Tonight's work is on "Landscaping", which means hopefully by this time tomorrow you'll be able to raise, lower, and even up land… that's the theory at least…

July 06, 2006

Vehicle Cameras and New Road Building

Bit of a gap since my last entry, but I'm really back in full swing now, and hope for a productive few months.

Road building/networks have almost be completely rewritten from scratch to make it infinitely more useable, now no knowledge of "where" to click in a square is required.

In a previous post I showed off the multiple "View Windows" which were essentially a view of the world through a separate camera, however at the time they simply showed the same view as the main camera. Fortunately now, these windows can now not only be in a different place in the world, but also follow vehicles around!

Today's video is slightly larger than before, 15MB, still Xvid, and demonstrates the new road building and a working Vehicle Camera in a window. Here it is. Enjoy.

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