Saturate (HLSL reference)

Clamps the result of a single or double precision floating point arithmetic operation to [0.0f...1.0f] range.

_sat

 

The saturate instruction result modifier performs the following operation on the result values(s) from a floating point arithmetic operation that has _sat applied to it:

min(1.0f, max(0.0f, value))

where min() and max() in the above expression behave in the way min, max, dmin, or dmax operate.

_sat(NaN) returns 0, by the rules for min and max.

Minimum Shader Model

This modifier is supported in the following shader models.

Shader Model Supported
Shader Model 5 yes
Shader Model 4.1 yes
Shader Model 4 yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

 

Instruction Modifiers