Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Add step and smoothstep functions #75

Open
SpotlightKid opened this issue Sep 3, 2024 · 4 comments
Open

[FR] Add step and smoothstep functions #75

SpotlightKid opened this issue Sep 3, 2024 · 4 comments

Comments

@SpotlightKid
Copy link

SpotlightKid commented Sep 3, 2024

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

@SpotlightKid
Copy link
Author

Yes.

@SpotlightKid
Copy link
Author

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

@SpotlightKid
Copy link
Author

Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants