Skip to content

[FR] Add step and smoothstep functions #75

Closed

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.

Activity

  1. SpotlightKid commented on Sep 3, 2024

    @SpotlightKid
    Author

    Yes.

  2. SpotlightKid commented on Sep 19, 2024

    @SpotlightKid
    Author

    Do you need any more info to be able to implement this?

  3. SpotlightKid commented on Oct 16, 2024

    @SpotlightKid
    Author

    Any progress on this?

  4. treeform commented on May 25, 2026

    @treeform
    Owner

    Thank you for the issue. I have added smooth step over in this PR: #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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