Summer Work (Day 15)
Planet Coloring pt.1
Today I managed to finish the terrain generation for now and have moved on to giving the planet some color.
The last thing I did to round out the terrain generation was to clean up those noise settings that I created last time. I wanted for only corresponding noise settings to be displayed in the details panel. In the Unity tutorial, this required editor scripting. I thought that this could have been taken care of by something more simple in Unreal like property specifiers or something (Spoiler: This was correct, but it would take some time before I would realize this).
After scanning the UPROPERTY specifiers page and found the metadata specifier EditCondition="BooleanPropertyName". This took in any bool including anything you could format into a C++ expression which is quite cool. I used this to say that the properties could only be edited when the corresponding enum is selected (eg. EditCondition = "FilterType == 0"). I was tempted to quit here, seeing that it would be impossible to edit the wrong settings. But at the same time, the clutter of the settings being there was not solved so I continued on.
The first thing I came across was the documentation for details panel customization. This is super neat and really shows how you can modify the editor for your specific needs. I also found this training video that shows some of these things in action. It all looked like quite the time investment though, so I went on trying to find something that was a little more simple.
This is when I stumbled across ILayoutDetails, mainly from this answerhub thread. This details all the ways you can edit the way properties behave in the editor. I thought this would for my purposes because I had my own variable class for these settings. The more I looked into this though it seemed less and less like what I wanted to do, and more and more like more work for me so I continued looking.
The answer to all my prayers came in the form of the last post on this UE discussion on the same topic. Alistairwick writes:
"You can also hide properties using the EditCondition as of 4.24! Just add the EditConditionHides meta tag.
Code: UPROPERTY(EditAnywhere, meta=(EditCondition="bBoolProperty", EditConditionHides))".
So this means that from the start I was on the right track, but because the documentation wasn't up to date I couldn't find the EditConditionHides attribute. I was incredibly mad at the unreal engine team for sending me on this wild goose chase, but also relieved that my problem had been solved in a clean and easy way. I then realized that had the solution been available from the start that I would never have learned about those other things; so I guess we'll call it even.
With the terrain generation being complete for now I finally pivoted to coloring the planet. The first thing to do is to basically get a heightmap from the lowest point on the planet to the highest. That part was easy, just compare each point when it is generated, but actually getting it to show up on he planet was difficult. The two roadblocks preventing me from doing this were 1) getting the min/max values from C++ into the material, and 2) mapping those values to object space.
The first problem stumped me for a good while. I was confused by what the differences between materials, material instances, dynamic materials, and material parameter collections were. Through lots of trial and error that I won't explain, I found that what I wanted was dynamic materials. I could create a dynamic material, inheriting from the regular planet material, and could change vector properties that would apply to a node in the parent material's editor graph with the same name.
Once I figured that out though, I had no idea if it worked because I still didn't know if it was mapping those values correctly to object space because I was using the ObjectPositionWS node without know what exactly it did. Looking at the documentation I decided it wasn't what I wanted and decided to do some looking around. I resorted to searching keywords in the new node window of the graph which resulted in me finding the LocalPosition node. Finally all the stars aligned and I got my desired heightmap.
For the simple colors that I want right now, I will just map a color gradient to the height and that will be that.
Comments
Post a Comment