If you want to make a videogame, yes.
If you need to make cinematics or whatver, no. You can use the engine stuff since Performance doesn’t matter.
The code you were given above is trash.
You dont do arcosine or any expensive operation on each vertex
Just do dot. And manually tweak a map range clamped value.
If you really have to use a bad runtime solution…
Further, IF used that way doesn’t support branching.
So its essentially pointless (and creates a hard edge line).
Probably just output of maprangeclamped into a lerp alpha in which A and B are 0 to 1.
Preview that on a landscape to determine if the value ranges appear Ok enough or if they need further refinment.
If you still get a hard edge regardless. That’s because of the map range clamped values.
Alterning those would make the transition into the slope value you want harder or softer.
As a general rule of thumb, to lessen the hard lines that the landscape gives you due to the fact that 1 pixel is a meter, you use another texture to blend the layers - somethimes called a height lerp when not done manually.
Again, put your heightmap into a GIS program.
Get a PNG of the slope and change it up artistically however you think you need to
(The output is a regular png, does not need to be 16bit).
Use that peoduct as the Paint Layer for the material that you want the slope to be covered with.
And then you can mess with the material’s layers however you think you need to.
Once its pre-defined you dont really have to worry about anything.
And PS:
No, if you want to set a degree value you still dont do the calculations on every vertex and complain about performance, unless you are mentally ill…
Make a BP that does the value conversion once and feeds it to the material as radians by altering a MPC (material parameter collection), if you want to be “sophisticated” about a pointless system.
Again, its completely pointless. Landscapes cannot be changed at runtime. Having runtime calculations is silly.