clamp
Description
Clamp. Returns the specified value clamped to the specified minimum and maximum bounds.
Signature
T clamp<T>( T x, T minBound, T maxBound) where T : __BuiltinIntegerType; vector<T, N> clamp<T, N:int>( vector<T, N> x, vector<T, N> minBound, vector<T, N> maxBound) where T : __BuiltinIntegerType; matrix<T, N, M> clamp<T, N:int, M:int>( matrix<T, N, M> x, matrix<T, N, M> minBound, matrix<T, N, M> maxBound) where T : __BuiltinIntegerType; T clamp<T>( T x, T minBound, T maxBound) where T : __BuiltinFloatingPointType; vector<T, N> clamp<T, N:int>( vector<T, N> x, vector<T, N> minBound, vector<T, N> maxBound) where T : __BuiltinFloatingPointType; matrix<T, N, M> clamp<T, N:int, M:int>( matrix<T, N, M> x, matrix<T, N, M> minBound, matrix<T, N, M> maxBound) where T : __BuiltinFloatingPointType;
Generic Parameters
T: __BuiltinIntegerType
N : int
M : int
T: __BuiltinFloatingPointType
Parameters
x : T
The value to clamp.
minBound : T
The minimum bound.
maxBound : T
The maximum bound.
x : vector<T, N>
The value to clamp.
minBound : vector<T, N>
The minimum bound.
maxBound : vector<T, N>
The maximum bound.
x : matrix<T, N, M>
The value to clamp.
minBound : matrix<T, N, M>
The minimum bound.
maxBound : matrix<T, N, M>
The maximum bound.
Return value
The clamped value.
Availability and Requirements
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
cuda
Available in all stages.
metal
Available in all stages.
wgsl
Available in all stages.
spirv
Available in all stages.