Skip to content

[FR] Add step and smoothstep functions #75

@SpotlightKid

Description

@SpotlightKid

... so they can be used with shady.

Here are implementations for float (after the example here). Should be relatively easy to make them generic:

proc step*(a, x: float): float =
  if x < a:
    0.0
  else:
    1.0

proc smoothstep*(a, b, x: float): float =
  # Scale, and clamp x to 0..1 range
  let x = clamp((x - a) / (b - a), 0.0, 1.0)
  x * x * (3.0 - 2.0 * x)

Then update shady to add these functions to glslFunctions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions