Process in the project is now a bit ahead of the blog, so maybe it is time to write about the progress and start with the view frustum culling.
Last time a mentioned a was going to start with the view frustum culling. What it do is it will cull objects that is not in camera view to optimize as much as possible.
Here is a picture of the result. For debugging purposes made it possible to “look” the camera, so I can get back and look how it works. And for now it is working great.
As you also can see in the picture is that the ground is not green anymore! Yes, I have started looking into the texture part. Which will get different textures depending on the height of the ground. So looking towards work more with it so it turn out good, so it hopefully in the end, look something like a planet.
With the new fixed level of detail, it was time to make som terrain. For a flat ground, have I formerly used highmaps for the terrain but using that for a terrain on a sphere was not an option. I wanted also to have a variegated terrain so the look of the planet could change. So for me I decided to use a variant of perlin noise called simplex noise. Simplex noise like perlin noise is a pseudo-random generator. Why using just simplex noise instead of a rand(), is that random number generators like rand, their output can be too harsh to appear natural. That simplex noise does is that it take an parameter, or more depending on implementation, and return a random number based on that parameter. If you pass it the same parameter twice, it produces the same number twice. Which will therefore make a smoothly generated numbers so they can easily be interpolated.
Here you have a picture of a small part of the generated terrain, and all made bu simplex noise. The appearance of the mountains looks good, and I am happy with the result. A picture I posted earlier in this blog showing you the result I had before with my terrain. The planet which looked more like a meteorite than a planet. Well, as you can se, now it is mountens when you are close to the ground as you are in the picture above.
And here you see how it looks like when you are high up in the sky. It is looking amazing, I am very pleased with the result. The picture with the mountain above is somewhere in the middle of the planet. Hard too see from here but it is there.
Right now it is a bit laggy, when detail is added and sertently when detail is removed. So up next will be to implement view frustum culling, which will make to only render and calculate detail where the camera is headed. So only the things that the camera is looking at, will be rendered and calculated.
As I mentioned yesterday, the detail level was not high enough to get the terrain effect I needed. I plan to solve this was to dynamic add more detail to the ground when the camera came closer and closer. So just add detail where it is needed. And that solution worked out very well!
I made an picture to try to explain how much of a difference it did. As you can see in the picture above, the one to the right was what I had first. This is one side of the cube, with 512×512 quads in it. Now you can see in the left image that I have increased the amount of quads from 512×512 to 16384 x 16384! And the red spot in the left image is how big the right image is now.
Last week we had Milestone 2, which went great. I presented all that I had done the last 2 weeks since Milestone 1. I have for the most worked on the sphere and the terrain. That is for me the most imported thing to get right. Without a good looking terrain, the planet will just be a big thing with some pits in the ground.
The picture above is representing my cube when I have not jet translate it to a sphere. Each side of the cube have 512×512 quads in it, like the red arrow pointing at. The problem I have is that I need much more quads in each side to the illusion that when you are far away, everything is just flat and the closer you get the more you will see some terrain popping up. But the make that happened I need as said more quads. And the way I are doing it now is that I calculate all quads when the program start and store everything in the memory for easy and fast access. But that is not possible anymore because the memory cant save 1024×1024 quads for each side, it´s just to many quads! So how will I solve this?
A solution I came up with is on frame decide if I need more detail where I am right now, thus, where the camera is. So then I is so close that the last quad in memory is showed and I am going closer to the surface. I then split that quad into four new quads and calculate everything for them now. So I only get more quads saved in memory then I need it. And if I getting away from the surface I just remove it from memory. Hopefully this is what I need so I get that detail that is required. Because more then 5120 quads is needed for get the right felling and so it will look like a planet in the end. I have already started with it and hopefully you will get an update on the progress tomorrow.
Today is it Milestone 2 so going to talk about what I have done the last 2 weeks. Present test of concept and show the sphere with level of detail. Also going to talk the problem a have encountered. Going to write more about that after the presentation. Also going to show you the first terrain I have come up to.
Looking good, except I had not in mind to make an meteoroid, I want to make a planet. There you have a hint about the problem.
Today was a good day. Because today level of detail is working perfectly. That you can see in my earlier post is that I am working with an cube that I i transform to an sphere. So for the level of detail I use each side of the cube as a starting quad, then i split each side/quad up in 4 new quads. So each quad have 4 children as I call them. And so on I do this 10 times. So I end up with a cube, there each side of the cube have been split down to 512 smaller quads. Depending on the cameras distance to all quads, them nearest will be rendered. SO depending on the distance quads will be rendered of call their child quads to see if they are close enough to be rendered.
Here is an picture of the implemented level of detail on the sphere. As you can see, the “camera” in this picture is near the circle in the middle of the sphere.And the quads further away is getting bigger and bigger the further away they are.