December 30, 2014

Substance Lab: Creating the functions in matfx_HeightAdjust

When creating matfx_HeightAdjust, i wanted a way to adjust the intensity of my height maps in Painter on a per-layer basis. Painter height maps always look more intense than Designer normal map and i needed a way to balance it. I also knew at that point how Painter was remapping the grayscale of my height map (see this for a quick run down) and so I knew that applying a level pushing toward black (or white for that matter) wasn't the correct solution. Blending the height map with a 0.5 gray was working, but gave me some artifacts (and didn't felt like the elegant solution...).

Warning: A little bit of math and logic is involved. As artists, this isn't our cup of tea, but bear in mind that it's for a good cause. (the following might seems to simple for the most math inclined of us but I've decided to explain it for those, like me, who feel a bit rusty when math is involved...)

So, there was, at that point, a list of variables that i knew:
  • Painter "neutral" point was 0.5
  • I wanted my intensity slider to be from 0 to 1, like everything else in PBR
  • I wanted my low and high output to move at the same time.
The range of my intensity slider was from 0 to 1, and the low and high output ranges were exactly half (Low: from 0 to 0.5, High: from 0.5 to 1.0). At 1, my level node need to be fully opened (low: 0, high:1) and 0, fully closed (low and high at 0.5).

Both functions are starting by getting the Intensity slider and dividing the value by 2. Then I add (level out high) or subtract (level out low) it from 0.5. That way, when Intensity will return 0, both output will return 0.5.

Here's what Level Out High function look like:


And Level Out Low:


So there you are, one parameter affecting two simple functions in similar yet different ways.

cheers

No comments:

Post a Comment