3.10 Discontinuities

There are several functions which “clamp” their inputs in various ways, i.e. potentially lose some information in their inputs and introduce discontinuities. These are documented in Tables 3.21, 3.22, and 3.23. The first set of functions are sharp discontinuities, the second supports smoothed discontinuities, as required in shaders for antialiasing. The smoothed version of a function typically has smooth in front of the name and an extra parameter for setting the width of the transition region.





Operation r <-- a,b,c,... Description






abs  N <-- N Componentwise absolute value
ri <-- |ai|



ceil  N <-- N Componentwise ceiling
r <--   |~ a  ~| 
 i     i



/ E  clamp  N <-- N,N,NComponentwise clamping of ai between bi and ci



/ E  clamp  N <-- N,1,1 Componentwise clamping of ai between bi and ci



floor  N <-- N Componentwise floor
ri <--  |_ ai _|



/ E  frac  N <-- N Componentwise fractional part
ri <-- ai-   |_ | ai|  _|



/ E  mod  N <-- N,N Componentwise floating-point modulus
ri <-- ai/bi-  |_ ai/bi _|



/ E  round  N <-- N Componentwise nearest integer
ri <--  |_ ai + 1/2 _|



/ E  sign  N <-- N Componentwise sign
ri <-- ai/ |ai|



 


Table 3.21: Clamping functions. These operations all potentially lose information and introduce discontinuities.





Operation r <-- a,b,c,...Description






max  N <-- N,N Componentwise maximum
ri <-- max(ai,bi)



/ E  max  1 <-- N Tuple maximum
r <--  max(a ,a ,...,a    )
           0 1      N -1



min  N <-- N,N Componentwise minimum
ri <-- min(ai,bi)



/ E  min  1 <-- N Tuple minimum
r <-- min(a0,a1,...,aN- 1)



pos  N <-- N Componentwise maximum with 0



/ E  sat  N <-- N Componentwise minimum with 1



 


Table 3.22: Minimum and maximum functions.





Operation  r <-- a,b,c,... Description






/ E  smoothstep  N <-- N,N,N Linear smooth step of ai centered around bi with width ci



/ E  smoothpulse N <-- N,N,N,NLinear smooth pulse of ai between bi and ci with width di



 


Table 3.23: Smooth clamping functions.


Note: This manual is available as a bound book from AK Peters, including better formatting, in-depth examples, and about 200 pages not available on-line.