Intrinsics1 min read
isfinite
Componentwise test for finite floating-point values.
Reading Time
1 min
Word Count
88
Sections
7
Try It Live
Test isfinite in a live shader
Open the playground, start from a visual preset, and wire isfinite into the fragment stage to see how it behaves with real values.
Open PlaygroundThe isfinite function returns true for values that are not NaN and not positive or negative infinity.
Live Demo
Signature
bwsl
isfinite :: (float x) -> bool
isfinite :: (float2 x) -> bool2
isfinite :: (float3 x) -> bool3
isfinite :: (float4 x) -> bool4
Parameters
| Parameter | Type | Description |
|---|---|---|
x | float, float2, float3, float4 | Value(s) to classify |
Return Value
Returns a bool or boolN where each component is true when the corresponding input is finite.
Example
bwsl
float exposure = exp(resources.exposure);
float3 hdr = color * exposure;
if (!all(isfinite(hdr))) {
hdr = float3(0.0);
}Compiled Output
When compiled to GLSL:
glsl
isinf(x) == false && isnan(x) == false
When compiled to HLSL:
hlsl
isfinite(x)
When compiled to Metal:
metal
isfinite(x)