I've spent the last couple weeks wrapping up all of the SRTM stuff. So in my last post I had started working all the data through the SRTMSplitter tool. One thing that I had noticed was odd was that it seemed like my units of data was way off, like all the elevation seemed way too high. I realized after spending some time poking around in the math that nothing was actually off, the reason that the elevation seemed so high was that because we were viewing all of North America at this scale it makes the high's in the terrain seem way higher than when all the data is zoomed in close and becomes spread out over a huge distance. So for the time being to counter this while I'm testing out the different levels I've just scaled back the height values.
I also spent some time getting some better camera controls in. Previously all I had was the ability to look left,right and move the camera forward/back/left/right/up/down. This kind of sucked though when I was trying to view the terrain from really high up. I had to pull the camera way back to see anything. I had already put some code in place for doing this but it seemed my math was slightly off because the view went totally wonky when I started adding the rotation around the x-axis( looking up/down ). To solve the problem I had to rejig the math so that instead of using a 6 degrees of freedom camera system it was more of a first person camera system so the camera can never rotate around the z axis.
With the camera updates out of the way the next thing I thought I'd work on was getting the multi-threading working again with the new terrain tree system. The idea was that I have these builder objects which are passed through the terrain tree and at each node they collect the necessary data to build the voxel data for that node. So I set up a BuilderThread object, how it works was that every frame the main thread queries the builder thread to see if it's ready to accept a new collection of builder objects. If it is ready then the new collection of builder objects is passed to the builder thread. The builder thread then starts building up all the voxel data. Once the thread has finished a flag is set so that the next time the main thread queries, all of the data which needs to be built on the main thread gets fired off and the cycle is complete ready for a new set of data. I had some problems with popping terrain but I just had to re-juggle when I was creating and destroying terrain chunks. Basically what I did was to always keep the parent terrain chunk around so that if we destroy the children we have something to pop back to when we render.
One more thing I had to take care of was splitting the terrain based on the distance of a node from the camera, this is the way chunked lod terrain works. I worked it out as an equation where there's an inverse relationship of the dimensions of a node to the distance from the camera. After a little bit of tweaking the equation I had it working perfectly how I wanted. It was a good thing I had the threading working because with the new splitting there was a lot more terrain splitting going on then the simple quad tree splitting that was going on before.
Now I was running into performance problems again. One of the big issues was a huge amount of overdraw. The problem was that when I first got the voxel terrain sprites working I didn't spend any time getting the skirts of the boxes working properly so every box with a skirt had it's skirt being rendered all the way to 0 m above sea level. It was a super simple fix I just had to tweak my function that was generating each block of terrain so that it was calculating the skirt based on the lowest level neighbour. This gave me a significant performance boost, enough that I could keep going on adding more functionality.
So the last thing I spent some time with was the rendering. I had been spending so much time getting this new functionality in but no time with how the demo was looking. So I spent some time retweaking the fog, the sky color, and the terrain colors so there's more of a gradient and the colors make more sense. I chose yellowish for near sea level, green in the midranges, and white for the highest elevations.