Range mapping

   8591   6   2
User Avatar
Member
164 posts
Joined: Feb. 2014
Offline
Hi,

I'm new to Houdini, coming from Cinema 4D.

How do I re-map values in an expression? In C4D it'd be a range mapper node (in Xpresso). Or in AE this https://forums.creativecow.net/thread/227/15487 [forums.creativecow.net]

Thanks
http://simonfarussell.com [simonfarussell.com]
User Avatar
Member
443 posts
Joined: Sept. 2012
Offline
for remapping values there is:
fit() and fit01()
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
yep fit() will work…
it would be helpful to pop open the textport ( alt+Shift+t)
then type help or exhelp
and if you're searching for something and don't know what it is try:
eg >> help -k range
which will list all the expressions/functions that have the word ‘range’ in it's documentation, so with the above you'll get all of these:
help -k range
chadd chread fplayback opextern render
chaneditor chrefit fps oplayout tcur
chkeyget chreverse frange oplegacyinputs tmgop
chkeyls chstretch fset opsave tset
chkeymv chwrite ftimecode opspare viewlayout
chkeyrm fcur opcook play viewwrite
chopview

exhelp -k range:
clamp fit01 fit11 pulse smooth turb
fit fit10 pointpattern

then you can do just:
exhelp fit
float fit (float num, float oldmin, float oldmax, float newmin, float newmax)
REPLACED BY
hou.hmath.fit()

Fits a value from one range to another.

Return a number between newmin and newmax that is relative to num in the
range between oldmin and oldmax. If the value is outside the old range,
it will be clamped to the new range.

EXAMPLES
fit(3,1,4,5,20)=15


RELATED
* fit01
* fit11
* fit10float fit (float num, float oldmin, float oldmax, float newmin, float newmax)
REPLACED BY
hou.hmath.fit()

Fits a value from one range to another.

Return a number between newmin and newmax that is relative to num in the
range between oldmin and oldmax. If the value is outside the old range,
it will be clamped to the new range.

EXAMPLES
fit(3,1,4,5,20)=15


RELATED
* fit01
* fit11
* fit10
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
164 posts
Joined: Feb. 2014
Offline
Thanks! And thanks for the detailed response!
http://simonfarussell.com [simonfarussell.com]
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
fit() yes.

It is common to do the following for any input parameters to give artist control of output:

chramp(“ramp_name”, fit(value, min_in, min_out, 0, 1), 0) * amplitude

This gives you a ramp to remap the range that you want coming in. Since the ramp works best with input values of 0-1, that's what you feed it with the ramp. You need to Edit Parameters and add the ramp as a spare parameter to work with.

Then use the amplitude to drive the overall scale. This is used all over Houdini including remapping values in various simulations.

See the example file for both expression way and VOP way. VOP way is far more accessible to c4d users imho as it could be turned in to an HDA and artist then doesn't care. Just add node, put in name of attribute to modify, tweak in values, ramp and final amplitude. Done.

Attachments:
fit_remap_values_expr_and_vops.hip (126.3 KB)

There's at least one school like the old school!
User Avatar
Member
164 posts
Joined: Feb. 2014
Offline
Thanks Jeff, this is great. I really appreciate the examples.

Presumably the expression method could be turned into a HDA but it'd just need some more work to create the correct interface?

jeff
to give artist control of output:
Unfortunately I am the artist It's only my first week exploring Houdini so there's a lot to take in but loving it so far.
http://simonfarussell.com [simonfarussell.com]
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
Any network can be turned in to an HDA. You can create all your custom parameters and reference them in to your expression.

For example, you would need two float parameters for the in_min and in_max values, one spline ramp parameter and an additional float parameter for the final amplitude. It would look just like the interface in the third VOP SOP example in the above hip scene file.

Expression would look something like:

ch(“../amp”) * chramp(“../ramp”, fit($VALUE, ch(“../in_min”), ch(“../in_max”), 0, 1))

where $VALUE would be your varying input that you are working with.
The ../ path reference is a relative path reference in case you don't know. The ../ means go up one directory which would land you at the parent node's parameter interface to find the channel by name.

Keeping things relive is a must with HDA's. Actually if you do have a full path, when you convert to an asset, they all get re-set as relative paths for you.
There's at least one school like the old school!
  • Quick Links