Hello everyone,
As Substance Designer 6 introduced new bit depths for nodes (L16F and L32F), some new opportunities and new possible workflows come to life. To facilitate them, I've accidentally created a new node that I thought would be great to share.
The
Auto Levels Plus node allows automatic remapping of an input image to a custom range specified by input parameters. Basically, it works just like you would expect from an Auto Levels node, but with two added benefits:
1) You can remap to a custom range, like to 0.5 - 1 or any other.
2) The node supports HDR data, so an input image can be of any available bit depth (L16F or L32F too).
I have tested the node for some time, but there could be bugs or corner cases when it may not work as expected. Please report such occasions in this thread so I could take a look at them and possibly come up with a fix.
Additional considerations before using the Auto Levels plus node:
The node uses this formula to remap values: NewValue = (OldValue - OldMin) * (NewMax - NewMin) / (OldMax - OldMin) + NewMin. So, at the core, it should be mathematically accurate.However, finding the OldMin and OldMax is quite an expensive operation, so at higher resolutions (2k+) performance would start to drop quite a bit.
To alleviate it, the node makes sampling for OldMin and OldMax values in lower resolution. Though there are some countermeasures, in some cases when resolution optimization is too extreme for a given image, due to downsampling OldMin and OldMax values can be sampled inaccurately (a small bit higher or lower than they are in fact). Most of the times, however, countermeasures mentioned above tend to work great, so it will produce a mathematically accurate result at a good speed for most cases.
One more note: in preliminary tests I've spotted some strange occurrences when the image is being remapped to a range other than 0...1. It was possible that some pixels would get a value a little bit off this new range. For example, if you remap it to a range of 0.41 - 1, some pixel сan get a value of 0.409998 or like that. I believe this is a precision issue due to operating with Float values, but I'm not sure about it. As a workaround, I've decided to clamp such "stray" values — in practice, it shouldn't cause any problems, as the margin of error there is minuscule.
Some images to illustrate the node are below and here is a download link:
https://forum.allegorithmic.com/index.php?action=dlattach;topic=15281.0;attach=23839Cheers!