![]() |
|
MATHS: CLAMP |
| Home | Tutorial Links | My Tutorials | Sample Materials | Freebies |
MATHS FUNCTIONS: CLAMPThe clamp node takes the value of Input_1 and replaced any value under zero with zero and any value over 1 with 1. This can be very useful towards the end of a series of calculations to strip out extreme results. Input_2 is ignored by the clamp node. The clamp node is normally used on the results of a series of other calculations. However, it is possible to get one interesting effect with just the clamp node and one unmodified input. Figure One shows the clamp node being used to clip off the top of a fBm node. The output is split between a smooth white area (everywhere in the original node that was over 0.5), and darker areas (everywhere originally under 0.5). This can be used to produce an interesting displacement effect - eroded rock or cracked concrete spring to mind. The key to this effect is the Value_1 attribute, set to 2. This multiplys the original fBm output by two, spreading it over the range 0 to 2. The clamp node then eliminates everything over 1. If you look at the preview window of your clamp node, you will not see any difference from the original input. This is because the preview window shows any number lower than zero as black, and any number higher than one as white. When not to use Clamp.There are several occasions where the clamp node might seem to be useful, but is in fact not needed. This is because some nodes automatically perform a clamp on the key input. The main examples of this are the Coloramp node and the blender node, where the controlling input is automatically clamped.. When to use Clamp.I have found the clamp node most useful when used with displacement or bump effects, where it allows you to create flat surfaces at the top or bottom of your displacement map. TransparencyAt first glance, transparency might seem to be in the 'when not to use' catagory. After all, something can't be more than totally transparent or totally solid. However, here the situation is a little more complex. If transparency_edge and transparency_falloff are both set to zero, then using the clamp node on your transparency map will have no effect. However, if the edge or falloff are set to a higher value, then using the clamp node will make a difference, producing less transparent objects. Example Materials using ClampThe Eroded Rock material uses the clamp node to produce the smooth surface. |