Begining optimization

I’ve begun optimizing the terrain, or rather, I’ve begun implementing the optimization functions. It’s not trivial, and it’s taken quite a lot of thinking and throwing away ideas as I figure out how to do different parts of it. Also, I have no experience with these kinds of things. But thats part of the reason I want to do this project, not to mention part of the fun! 🙂

The terrain is now stored in memory as a quad tree. The program will first create a large square representing the entire terrain, and then split these into smaller bits. At some point these smaller squares will be the same size as one tile, and at this point each square, or node in the tree if you like, is saved. These are used when creating the actual tiles. The result when only rendering each tile?

Maximum optimization

Maximum optimization

Not very pretty, but quite fast. However, I can create some additional levels in the optimization tree, and it starts to look quite a bit better.

Medium optimization

Medium optimization

As you can see, the terrain is quite detailed, even if it’s using a lot fewer polygons. But I’m not done. I want to have optimization based on the terrain itself, that is, if the terrain is hilly and interesting I want to keep that information and use lots of polygons to render it, but if it’s flat and boring I want to optimize more. I would also like to tie the level of detail to the range between the tile and the camera.

So thats what I’m looking into right now. It’s quite difficult, so I’ll probably spend some time wrapping my head around it and implementing it. I’ll update as soon as I have something though. 🙂

I did find one trick for improving the speed however. When I lowered the size of each tile, the program began to run faster. Right now, each tile is 32 squares wide and deep. My (educated) guess is that moving each tile to OpenGL was a big bottleneck. The program is set up so each tile is rendered by itself. So when I lowered the size of each tile, OpenGL could render it while I moved the next one to the GPU. Well, I think thats why. Works good anyway. 🙂

-Knut

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: