<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ShaderGraph-Docs",
  "identifier" : "/documentation/ShaderGraph/Math/Clamp",
  "metadataVersion" : "0.1.0",
  "role" : "ShaderGraph Node",
  "symbol" : {
    "kind" : "ShaderGraph Node",
    "modules" : [
      "ShaderGraph"
    ],
    "preciseIdentifier" : "Shader_ND_clamp_float"
  },
  "title" : "Clamp"
}
-->

# Clamp

Clamps the input per-channel to a specified range.

## Parameter Types

**Clamp (float):**

|Input |Type |
                |------|-----|
                |`In`  |Float|
                |`Low` |Float|
                |`High`|Float|

|Output|Type |
                |------|-----|
                |`Out` |Float|

**Clamp (vector3f):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector3f|
                |`Low` |Vector3f|
                |`High`|Vector3f|

|Output|Type    |
                |------|--------|
                |`Out` |Vector3f|

**Clamp (vector2f):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector2f|
                |`Low` |Vector2f|
                |`High`|Vector2f|

|Output|Type    |
                |------|--------|
                |`Out` |Vector2f|

**Clamp (vector4f):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector4f|
                |`Low` |Vector4f|
                |`High`|Vector4f|

|Output|Type    |
                |------|--------|
                |`Out` |Vector4f|

**Clamp (color4f FA):**

|Input |Type         |
                |------|-------------|
                |`In`  |Color4<Float>|
                |`Low` |Float        |
                |`High`|Float        |

|Output|Type         |
                |------|-------------|
                |`Out` |Color4<Float>|

**Clamp (vector3h):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector3h|
                |`Low` |Vector3h|
                |`High`|Vector3h|

|Output|Type    |
                |------|--------|
                |`Out` |Vector3h|

**Clamp (half):**

|Input |Type|
                |------|----|
                |`In`  |Half|
                |`Low` |Half|
                |`High`|Half|

|Output|Type|
                |------|----|
                |`Out` |Half|

**Clamp (vector2h):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector2h|
                |`Low` |Vector2h|
                |`High`|Vector2h|

|Output|Type    |
                |------|--------|
                |`Out` |Vector2h|

**Clamp (color3f FA):**

|Input |Type         |
                |------|-------------|
                |`In`  |Color3<Float>|
                |`Low` |Float        |
                |`High`|Float        |

|Output|Type         |
                |------|-------------|
                |`Out` |Color3<Float>|

**Clamp (vector3f FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector3f|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector3f|

**Clamp (vector2h FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector2h|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector2h|

**Clamp (vector4h):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector4h|
                |`Low` |Vector4h|
                |`High`|Vector4h|

|Output|Type    |
                |------|--------|
                |`Out` |Vector4h|

**Clamp (vector3h FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector3h|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector3h|

**Clamp (vector4h FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector4h|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector4h|

**Clamp (color3f):**

|Input |Type         |
                |------|-------------|
                |`In`  |Color3<Float>|
                |`Low` |Color3<Float>|
                |`High`|Color3<Float>|

|Output|Type         |
                |------|-------------|
                |`Out` |Color3<Float>|

**Clamp (vector2f FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector2f|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector2f|

**Clamp (color4f):**

|Input |Type         |
                |------|-------------|
                |`In`  |Color4<Float>|
                |`Low` |Color4<Float>|
                |`High`|Color4<Float>|

|Output|Type         |
                |------|-------------|
                |`Out` |Color4<Float>|

**Clamp (vector4f FA):**

|Input |Type    |
                |------|--------|
                |`In`  |Vector4f|
                |`Low` |Float   |
                |`High`|Float   |

|Output|Type    |
                |------|--------|
                |`Out` |Vector4f|

## Parameter descriptions

- `In`: The input to clamp.
- `Low`: The low end of the clamp range.
- `High`: The high end of the clamp range.

## Discussion

The `Clamp` node restricts the range of values of an input as defined by the `Low` and `High` parameters passed into the node.
The output of the `Clamp` node is the same as the `In` value if it falls within the defined range. Otherwise, the output clamps to the nearest limit, which is either the `Low` or `High` value.
Use the `Clamp` node to create more predictable and controlled shader behavior for materials.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)