Progress Update #3

 The Worst Bug


    So far I haven't maintained my promise to do an update every week, but it wasn't from lack of effort I can guarantee you. You see, because I'm not strictly following a tutorial, I'm not easily able to get answers to my problems. This is a result of that.

    So the gist of the problem I had was this: I wanted to have different noise affect the oceans and the terrain. Basically I wanted to get rid of these spindley bits that I thought didn't look nice.

    A simple problem right? Yes actually. All I had to change was, when adding noise to the elevation, check if the new elevation would be below 0 (sea level) and not add it. 

From:
elevation += elevation + NoiseFilters[i]->Evaluate(PointOnUnitSphere) * mask;
To:
float newElevation = elevation + NoiseFilters[i]->Evaluate(PointOnUnitSphere) * mask;
// Only use first layer noise for ocean shading
if (elevation + newElevation > 0)
{
	elevation += newElevation;
}

Now, this worked... but it had the unintended consequence of doing this

    This was the problem that took me four days top find the solution to. I'll spare you the boring and "pull my hair out" frustrations and say that after logging, clamping, and debugging basically every value I could in C++, I eventually concluded that the problem must be in the material. 
    I initially tried the DebugFloatValues node in the material graph, and it kind of worked but it didn't give me the information I wanted. Might be useful in the future though.

    
    I then noticed if you changed the color gradient for the ocean, that the bugged region of color would change. This meant that I started searching for the problem where the colors were added together. I then looked back to where the textures were each multiplied by either 0 or 1 depending if the pixel was on land or not. I decided to look at this 0 or 1 "mask" and saw this:

    What I was expecting to see was black where the ocean is, and white where there is land. But instead there were three shades of white *gasp*! This was the problem. Essentially the "floor" node rounds down to the integer and somehow got 1, 2, and 3 as outputs. This was then multiplied by the color, overloading it to that red-white color. 
    I knew that I only wanted this node to output 0 or 1 and nothing else so I came up with this solution:

Now I have smooth oceans but sharp perrain:

So what's next? I have a few things on my radar. The first is multithreading. This will speed up generation by a significant amount I would think. The next thing is redoing the texture system because I recently found this great article on how to save a procedurally generated texture as a new asset entirely through C++ which is exactly what I wanted before I decided on this whole Atlas system that has been nothing but a pain for me. Then I think I will try my hand at making some sort of orbital UI with a spline to show where planets will orbit without having to actually simulate those orbits. After all that is done I think I am finally ready to make what could start to resemble a game. 

Comments

Popular posts from this blog

Polishing the Foundation

Progress Update #13

A New Chapter