Skip to main content Link Menu Expand (external link) Document Search Copy Copied
roundedRectangleSdf2d

roundedRectangleSdf2d

SDF for a 2D rectangle with optionally rounded corners.

Each corner has a separate roundness setting, which can be used to make some corners round and others sharp.

See ShaderToy for example.

Parameters

  • Scale: The size of the rectangle along the X and Y axes.
  • Roundness: The distance of rounding for each of the four corners. When the roundness exceeds half the `Scale`, the rectangle will have discontinuities along the axes.

Inputs

  • Scale Field: (optional)
    • Coordinate Types: vec2
    • Context Types: Context MaterialContext CameraContext LightContext RayContext ParticleContext
    • Return Types: float vec4
  • Roundness Field: (optional)
    • Coordinate Types: vec2
    • Context Types: Context MaterialContext CameraContext LightContext RayContext ParticleContext
    • Return Types: float vec4