Wednesday, August 15, 2012

83 – A good first week

I continued working on the grass, removing the grid and adding real terrain underneath:

So the next step would have been to make the terrain larger and work a little on grass density and clipping. This is where I encountered a huge bug that took me hours to track down. I noticed that once in a while, under different terrain settings it looked weird, but at first I did not give it any further thought. Then when I got my terrain to where I wanted it and with the correct parameters, I noticed how wrong it was: it was very dark, the patterns of the repeating textures were a lot more visible and it ran like a total absolute piece of fish excrement. Like 3-4 times slower. I had another little hacked together project that started out from somewhere on the Internet and I ended up adding terrain here first sometime before my real try of getting terrain to work, so I made the terrain take the same parameters and it looked just fine. I was baffled and ended up creating several projects from scratch and incrementally modifying them until they ended up a carbon copy of the code from the mock-up project and still it did not work. I even diffed the source codes, shaders and textures and they were 100% identical. Then it hit me: if the source is identical, then maybe the project files were different. And they were. In XNA you have a "Content" project, where all the content is stored and transformed for deployment. In this project you have an XML file that contains information about all the entities and for the textures the information was different: it did not instruct on the creation of mipmaps. Now I have no idea why mipmaps are not built by default and how to do this from Visual Studio. Maybe because I am using the Express edition. Anyway, I fixed it by adding this to each texture in the XML file:

So if you suspect that something is wrong, try this! Somebody has got to pay for the time wasted tracking this down!

This is the result of my efforts: 

Now this looks decent, is less buggy and performs a lot better than previous versions (ignore the massive FRAPS snag in the middle of the video). With single pass grass and lower quality terrain it should work on anything. But there are still tons of problems with it:
  • While grass is chunked, terrain is not chunked yet, so it has pretty poor resolution. You can see how square hill tops are. I'll chunk terrain and then maybe I can get it larger, but for now I want to avoid really large pieces of terrain. Both as a design decision and a way to reduce work load. Implementing terrain LOD switching is a 2-6 week task depending on the quality of the switch.
  • Getting a texture tiling factor that looks good is almost impossible.
  • Getting one for distant terrains is very hard because if you set it too low, your textured will look detailed and non-repeating, but it will create the illusion of closeness. Those mighty hills in the distance will appear closer and smaller. Setting it too high will create and obvious repeating pattern. I did not set it to the optimal value, I had to compromise because of the next point.
  • Your distant texture tiling factor is the same to your close factor, and pretty much any value you select that makes distant lands look good will make the land under your feet look like shit. Selecting a tiling factor that makes close land look good is so high, that it will eliminate all detail from distant lands, making them look like smooth colored and shaded surfaces.
  • Grass does not look good in the distance unless it is scaled up to a ridiculous degree: about 30 times. So I had to scale it all up. A real solution would be to chunk it (already done) and scale it based on distance.
  • Distant grass should really be unanimated billboards.
  • The scale of the land is 128000x128000x20000. Pretty big. In the video you are walking/flying at greatly increased move speed, but even without this the land seems tiny. Scaling is all wrong. Partially because of grass. When I got the grass so high that it looked good in the distance, you couldn't see anything from the grass in first person mode while on the ground. It was a lot taller than you, so I had to raise the camera. Another reason is close land tiling factor. Raising the camera also makes close textures look less blurry and stretched.
So I'm pretty much done with the terrain for now. I'll continue working on the scale of it, trying to make that 128000 wide terrain actually look big and I'll also try a thing or two to make it look more interesting.

So this week: primordial procedural cities and physics!

No comments:

Post a Comment