Right now my program makes 64 different textures for the terrain, each of which fits over a particular zone. Right now all the textures are the same size, which is 256×256. This takes about 16MB of video memory. Not bad, but certainly not ideal. This means every zone, no matter how close or how far, has the same sized texture. Check it out:
In this set of textures, each one is 256×256 pixels. The entire set takes about 2 seconds to build and takes up 16MB of memory.
If you remember from previous updates, I need to rebuild all of the textures if I move the sun. (If I don’t, the terrain would look exactly the same, which would defeat the purpose of moving the sun. It needs to re-make the textures with the new shading and shadowing.) But right now it takes 2 full seconds to rebuild the textures. I have to “steal” that two seconds a few milliseconds at a time, unless I want the user to endure a long pause every time the shadows need to move.
But, we don’t need every dang texture to be 256×256. In fact, only the ones nearby do. Let’s make the texture size variable, so that the ones nearby have lots of detail and the ones far away have much less:
In this set of textures, the closest ones are 256×256 pixels, and the ones in the distance are 8×8. The entire set takes about 0.7 seconds to build, and uses just over 2MB of video memory.
I think I’m actually being too agressive here. The ones at the top that you can’t read are 16×16 and 8×8. They look pretty crappy, and I think 32×32 should be the minimum. Anyway, I need to calibrate this a bit, but it’s clear this is the way to go. I’m using a fraction of the memory I was before and the texture rebuild happens about three times faster.
However, this introduces a new problem. (Doesn’t it always?) Let’s assume this engine is being used in some sort of Sim City or RTS setting. The user may want to zip from their current location over to the other side of the map. When they get there, the area right in front of them will look like this:
Ugh. Not so nice.
So, while before I was worried about keeping shadows moving smoothly, now I have to keep these texture updates coming so the above doesn’t happen. If the user hurries accross the terrain, I think it would be a good idea to dedicate more time to the texture rebuild, so that I can come up with a new set of textures with the detail in the right place. This would mean that moving very fast from one side of the terrain to the other would lead to the framerate dropping and things getting choppy for a second until the texture rebuild gets caught up. This is acceptable in my book, as long as the game doesn’t require lots of fast hops around the terrain.
EDIT (July 6 2007): A much better idea, now that I’m thinking about this a year and a half later, for for each zone to hold onto several different resolutions. When I go to a new area of the map, it will build the higher res textures I need nearby, but it won’t throw away the high res ones I was looking at a second ago. It will just shuffle them out of use for a minute. If I come back, the textures go back into use. After a while, unused high-res textures are purged from memory. This means If I jump around between various “hotspots” the game won’t have to do a lot of texture rebuilding, and the game stays smooth.
A look back at Star Trek, from the Original Series to the Abrams Reboot.
A video Let's Play series I collaborated on from 2009 to 2017.
The Best of 2017
My picks for what was important, awesome, or worth talking about in 2017.
The Biggest Game Ever
Just how big IS No Man's Sky? What if you made a map of all of its landmass? How big would it be?
The Best of 2016
My picks for what was important, awesome, or worth talking about in 2016.