fuckingtech/public/assets/glsl/lygia/math/aastep.msl
Elias Rhouzlane bf76c6b086 fix: code
2025-04-06 17:23:52 +02:00

23 lines
No EOL
698 B
Text

/*
contributors: Matt DesLauriers
description: Performs a smoothstep using standard derivatives for anti-aliased edges at any level of magnification. From https://github.com/glslify/glsl-aastep
use: aastep(<float> threshold, <float> value)
option:
AA_EDGE: the absence of derivatives you can specify the antialiasing factor
examples:
- https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/draw/aastep.frag
*/
#ifndef FNC_AASTEP
#define FNC_AASTEP
float aastep(float threshold, float value) {
#if defined(AA_EDGE)
float afwidth = AA_EDGE;
return smoothstep(threshold-afwidth, threshold+afwidth, value);
#else
return step(threshold, value);
#endif
}
#endif