Summer Work (Day 16)

Planet Coloring pt.1.5

    Within the past day, I have managed to add full color to the planets. Although it took more time and effort than I would have expected, I am happy with the result.


    The biggest challenge I had to overcome was getting a color gradient. In Unity, there is simply a variable type 'Gradient' that gives you a nice small UI to pick colors and can be converted to a 2D texture that can be used in the shader graph. What's wrong with that? Well Unreal decided that wouldn't be complicated enough.
    So after a bit of searching online for "ue4 gradient" or "color gradient ue4", I came across this forum answer that introduced me to curves. So instead of having variable type 'Gradient' you would have 'UCurveLinearColor' because that's so much more intuitive. Then you will have to create a Curve of type LinearColor in the content browser. Now once you assign assign that variable in the details panel, and open the new asset, you will see that the simple UI from Unity has been replaced with an over-complicated menu that gives you more options than you will ever need in your lifetime. But for real though, it gives you lots of really cool options to mess with the colors, even if you won't need all of them at once.
    So now you have a color gradient, but how do you get that into the material? Good question. The answer is by creating another asset to bridge the gap between color and material. This asset is called a "CurveLinearColorAtlas" and you need it for the parameter in the material graph. But before that happens, you first have to plug your Color Curve from before into the new Atlas.


    Now to get all of that into the material. The node needed is called "CurveAtlasRowParameter". With that in your material graph, you can select the Atlas and "Row" which is the Color Curve that was added to it. At this point the curve can be hooked up to the rest of the graph and be functional.


    Here's where I ran into a problem. I wasn't able to figure out how to access the curve variable from within C++. All I was able to find were getters to for the Curve variable and I was unable to set it to the variable that I defined in the beginning. I hope to find a solution for this soon, but since it works right now I am satisfied.
    The second problem has to do with the curve itself:


    As you can see in the picture above, the "mountain" part of the texture starts at about .5 where it should be at 1 or the highest elevation on the planet. I did some testing to find out why this was and I think I have an answer. The min/max values that I made last time are working correctly and are also applied to the material correctly so it wasn't that. My suspicion is the problem lies in the LocalPosition->VectorLength value that controls the lerp (see second picture up). Somehow this value isn't quite reaching the max elevation of the planet so I will have to find some way to fix this in the future.


All current code available here: https://github.com/setg2002/CppGame

Comments

Popular posts from this blog

Polishing the Foundation

Progress Update #13

A New Chapter