Math behind the Mask by Feature Ramp Remapped Values

This is an explanation of the math of how the Height Ramp in the Height Field Mask by Feature node in Houdini is calculated.

In a video tutorial titled, “Height Field for Beginners”, I go over how to create a procedural terrain with Houdini.

The selected range on the Mask node is -93 to 125. This is the range that the ramp will be remapped to.

Tutorial HF MaskByFeature RAMP. range - Blue Indications.jpg
Tutorial HF MaskByFeature RAMP. 10 percent.jpg

So in this article we’re going to more concerned about how the pegs are remapped to height values from the selected range -93 to 125.

 
Height Ramp on Mask by Feature node represents a percentage range

Height Ramp on Mask by Feature node represents a percentage range

One thing to clarify is that this ramp, like any other ramp in Houdini represents a 0% (left most) to 100% (right most) range. The ramp uses position values from 0 to 1, but I want you to think of it as a percentage instead of a floating decimal value of 0 to 1. It will make it easier to explain the math.

 

The second peg on the Height Ramp (the blue arrow in the screenshot) is located at position 0.437322. I have estimated it to be 0.44, which represents 44% of the selected range.

125 - (-93) = 218

There are 218 units in between the selected range -93 to 125. If you were to count from -93 all the way up to 125, you would be counting 218 numbers along the way.

Now to calculate how much is 44% of the 218 units:

44% of 218
= 0.44 * 218
= 95.92

So now we now 95.92 units make up 44% of 218. 218 is the number of units in between -93 to 125.

If we add 95.92 to -93 we will get the remapped value of the 44%.

(-93) + 95.92
= 2.92
~ 3  (estimated at 3, because it's easier to write on the screen during filming in the video)
Tutorial HF MaskByFeature RAMP.   24 remapped value.jpg

The third peg remapped value is calculated the same way. The third peg’s position is located at 0.54, which represents 54% of the selected range.

And the selected range is -93 to 125.

So the math is very similar to the above:

125 - (-93)
= 218

So 218 is the number of units between the selected range.

And 54% of that 218 units is:

54% of 218
= 0.54 * 218
= 117.72

Therefore when we add that number back into the selected range, we’ll get the point where the 54% starts.

-93 + 117.72
= 24.72
~ 24 (estimated at 24, sorry I wasn’t very consistent with my rounding)