The last two weeks have been stressful and very much to do, to make as much as possible done for the milestones. MS3 was last week, and I was supposed to be as done as possible for the presentation. The presentation went okey, with some  feedback on what to improve to the presentation for MS4. They also wanted me to show my project in realtime and not with some videos, and that I should talk more about the process and what I had done to make everyting. And finally they wanted to see that it was possible to change the terrain and make differnet kind of planets att runtime. Which was not one of my goals with the project to have the possibility to change the planet at run time. Why they wanted that was to see that the planet was not made up in any modeling program as Maya or any similar. So with the way I had implemented everything, it could have take to much time to make it possible in runtime. So I made it possible before you start the program to change the parameters that change the terrain and make the appearance of the planet. Also added so so can change the color of the sky so it is not only blue with yellow/red/green sunsets, now it is up to you to make the sky as you want it!

So for MS4 presentation was everything up and running as it should, almost. When I was going up and start the presentation and present my program, of course the textures did not work, so everything was just blue and dark..  But on the computer which did not have the projector engaged too it, there it worked as it should. But I just show the teacher after the presentation, so he was satisfied. And I was so satisfied and pleased that the presentation was done and it had gone well.

So now is everything submitted and this project is now finished.

Want to thank you all how have been reading and hope this project have been fun and interesting to follow.

I end this last update with some result picture from my project.

SpacePlanet

The planet, how it looked on the presentation.

SpacePlanet2

Changed the frequency from 5 to 1 give you this planet look.

SpacePlanetSnow

 

Same frequency as the picture before but with higher amplitude, which gives you a planet with more snow.

behindPlanet

 

The planet from behind.

normalsunset

 

A more realistic sunset.

purpulsunset

 

Changing the wavelength from 0.750, 0.430, 0.400 to 0.410, 0.430, 0.600 will give you a sunset with a purple appearance in the sky.

 

Thank you, Once again! This have been a very fun project and I have learned a lot, but I am also glad that it is over.

With Best Regards
//Gustav Olsson

 

Something that I have had for some time now but have not write anything about is the atmosphere. On of my goals for the project was to get an atmosphere so I got a day and night circle. The technique I have been using is accurate atmospheric scattering to make the atmosphere. I have follow this tutorial from nividia (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html), which go through the theory behind the calculations and how the technique work. Briefly is that the scattering equations nested intergral which is numerically compute the value of the integral which go down to a weighted sum calculated in a loop.   Then if you take a imagined line segment and brake up the segment into n sample segments and evaluate the integrand at the center point of each sample segment. Then multiply each result by the length of the sample segment and add them all together. If you take more samples, makes the result more accurate, but then also makes the integral more expensive to calculate.

Another important detail is related to how the light scattering at the sample points. Different particles in the atmosphere scatter light in different ways. The two most common forms of scattering in the atmosphere are Rayleigh scattering and Mie scattering. Rayleigh scattering is caused by small molecules in the air, and it scatters light more heavily at the shorter wavelengths (blue first, then green, and then red). The sky is blue because the blue light bounces all over the place, and ultimately reaches your eyes from every direction. The sun’s light turns yellow/orange/red at sunset because as light travels far through the atmosphere, almost all of the blue and much of the green light is scattered away before it reaches you, leaving just the reddish colors.

Mie scattering is caused by larger particles in the air called aerosols (such as dust and pollution), and it tends to scatter all wavelengths of light equally. On a hazy day, Mie scattering causes the sky to look a bit gray and causes the sun to have a large white halo around it.

Some pictures of the atmosphere in my project. Showing one sunset!

newsunnewsunsetnewsunset1

 

With the reworked level of detail I was kind of back at square one again. So I have today worked with setting up the terrain again with textures and all. Before I did just use face normals for all quads which did the terrain look very hard and quadrangular which did not look to good.

groundshader

Here is a picture of how it did look before, it is well okey but not good looking.

normalmap

Here is a picture how it looks now, and I’am thinks it is looking better! What I am doing is that instead of just using face normals, I am now using a the face normala and then use a normal map to make a per pixel normals which make it all looks more smooth. But as you can see it is far from great, what am need is this with per vertex normals and then apply the normal map, but I am not getting that to work cause how I have build the structure with the quad-tree. So that was Something I kind of forgot and which will not make it to the final. But as  you can see now , I have implemented a atmosphere with blue sky and all! I am going to write about that soon but I am going do hold it a little bit longer.

And how do a  normal map look? The picture below is the one I did use for my terrain and that is pretty much how they look, blueish and they are used for faking the lighting of bumps and dents, which you can see if you are going close enough.

 

normal2

 

The prestanda problem have been solved! I now never dropping below 30 fps and mostly at 60. The changes I have made is that I have reworked the way I am update the level of detail. Before I did work with one quad at each time which led to lots of quads to run through to get to the last one in the tree. What I am doing now is that am working with chunks instead, and each chunk have 256 quads in it. Which decrees the total amount of objects to go through to get to the one that is going to be rendered. Just doing this increased the fps significantly. Have to work with getting rid of chunks when going out in space so I can save memory for later if I am moving close to the planet again and needs to calculate new chunks and allocate new memory.

Something that I really want to fix before deadline this Friday is to fix this prestanda issue I having when I update the terrain to be more detailed. That is a big problem which lowers the overall impression. I have now been siting the weekend and trying to fix the problem, i am on my way and I think that I may have a solution that will solve the problem. Hopefully, and very much needed, tis it fixed and working later today. So I will be enlighten you later today how all went, hopefully with a solution to my problem.

About the problem I had on building my program in release mode, I have found the issue. It have taking long time to track this problem down because you can not debug in release mode, so I though. But with some tweaking with the properties for the project in visual studios it was possible to track down where the error occurred. And it was when I tried to bind my vertexes, normal’s and uv to the graphic card. The glGenBuffers was where the access violation happened and I had no clue why. After some searching on the internet about my problem I find someone who had have the same problem. And he had find that it was a bug in Qt, which is a cross-platform application framework that I am using for my project. So apparently I needed to use something else to  initialize me opengl functions. So I had some problems getting that to work cause some things do not work with each other, some things need to be included before other things and so on. But eventually I got it to work. So now am using glew to initialize me opengl functions. So now I can build my project release mode! And it help me fps a lot. But I’m not entirely satisfied with the fps entirely jet. So I possible need to rework me LoD structure some how..

But some good news is that I have sun light on my planet now, and it is working good!

SunOnplanet

And what can that white thingy be? Can it be a atmosphere?!?

I was in the beginning of the project little afraid of not have enough time to make everything done in time for the deadline. With just a week left, much is to be done! So it will be some late night the coming days to hopefully make as much as possible done. One major problem for a starter is the low fps I have currently. When you are really close to the planet, you will just have around 10 fps, which is way to little. So this need to be fixed. And for the moment I have had major problem to make me project work in release mode, for it just gets error. But debug mode work just fine…
And in release mode you can not really see where the problem appears, which just make it even harder to solve the problem. But I have to solve it, so I can see how much of a fps problem I really have. So I am going to sit down and really try to  understand where the problem is, so I hopefully can get it to work.  So this will be the first step in making the program more efficient, so the fps can increased dramatically so it will be more smooth to play.

To make the textures blend nicely between each other was little more trickier then i though. All thou it is not hard to manage. I just did not see the hole picture to understand how what I was supposed to do, to make them blend. And now the funnetly blending, but it is not looking good, until I come really close to the planet and a more detail to the planet is slowly showing. Then really close, they are blending satisfying. And I have now started to make some sunlight to the planet so I  really soon can start with the atmosphere. Because it is not much left of this project so I need to hurry up a bit or two, if everything is going to be done in time!

With working view frustum culling I ave started looking into texturing. The different textures will be separated depending on the height.

fulfärg

 

As you can see in the picture above. You can see how depending on the height different colors are printed out. It is a start but I need them to blend nicely between each other.  So I do not have the hard edge between two colors.

 

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.
frustum

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.