roundedRectangleSdf2d

roundedRectangleSdf2d

sdf2d
roundedRectangleSdf2d
RayTK
v0.40

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

Name Description Regular Handling Read-Only Handling
Scale

The size of the rectangle along the X and Y axes.

Runtime Baked
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.

Runtime Baked
Roundness Unit Baked Baked
  • Distance:
  • Ratio of Scale:

Inputs

  • Scale Field: (optional)
    • Coordinate Types: vec2
    • Context Types: Context MaterialContext CameraContext LightContext RayContext ParticleContext VertexContext PixelContext
    • Return Types: float vec4
  • Roundness Field: (optional)
    • Coordinate Types: vec2
    • Context Types: Context MaterialContext CameraContext LightContext RayContext ParticleContext VertexContext PixelContext
    • Return Types: float vec4
    • Supports Variables From Inputs: scaleField