Skip to content

Instantly share code, notes, and snippets.

@pinkwerks
Last active March 2, 2022 01:49
Show Gist options
  • Save pinkwerks/e2dcf8c1a1e6252ad5e9544abead7e00 to your computer and use it in GitHub Desktop.
Save pinkwerks/e2dcf8c1a1e6252ad5e9544abead7e00 to your computer and use it in GitHub Desktop.
float frequency = .5;
float trianglewave = abs(2 * frac(x * frequency) - 1); // repeating triangle wave /\/\/\...
float squarewave = round(abs(2 * frac(x * frequency + .25) - 1)); // repeating square wave
float aaedge(float width)
{
vec2 uv = getBaseTextureCoordinates();
vec2 border = min( uv, 1 - uv );
vec2 fw = fwidth( uv ) * width;
vec2 g = saturate(border / fw);
return g.x * g.y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment