From 527226180d6dca125dc44ee9afc53ca8555fa9d7 Mon Sep 17 00:00:00 2001 From: shadielhajj Date: Sun, 7 Jul 2024 14:14:49 +0100 Subject: [PATCH 1/2] Added GLSL and HLSL versions of fcos. --- math/fcos.glsl | 18 ++++++++++++++++++ math/fcos.hlsl | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 math/fcos.glsl create mode 100644 math/fcos.hlsl diff --git a/math/fcos.glsl b/math/fcos.glsl new file mode 100644 index 00000000..74110deb --- /dev/null +++ b/math/fcos.glsl @@ -0,0 +1,18 @@ +#include "const.glsl" + +/* +contributors: Inigo Quiles +description: A band-limited variant of cos(x) which reduces aliasing at high frequencies. From https://iquilezles.org/articles/bandlimiting/ +use: fcos( value) +*/ + +#ifndef FNC_FCOS +#define FNC_FCOS + +float fcos(in float x) +{ + float w = fwidth(x); + return cos(x) * smoothstep( TWO_PI, 0.0, w ); +} + +#endif \ No newline at end of file diff --git a/math/fcos.hlsl b/math/fcos.hlsl new file mode 100644 index 00000000..5b8b5fb3 --- /dev/null +++ b/math/fcos.hlsl @@ -0,0 +1,18 @@ +#include "const.hlsl" + +/* +contributors: Inigo Quiles +description: A band-limited variant of cos(x) which reduces aliasing at high frequencies. From https://iquilezles.org/articles/bandlimiting/ +use: fcos( value) +*/ + +#ifndef FNC_FCOS +#define FNC_FCOS + +float fcos(in float x) +{ + float w = fwidth(x); + return cos(x) * smoothstep( TWO_PI, 0.0, w ); +} + +#endif \ No newline at end of file From 13bdac9da0f94db35115357e57695f92f321fcc6 Mon Sep 17 00:00:00 2001 From: shadielhajj Date: Sun, 7 Jul 2024 14:15:43 +0100 Subject: [PATCH 2/2] Indentation fix. --- math/fcos.glsl | 3 +-- math/fcos.hlsl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/math/fcos.glsl b/math/fcos.glsl index 74110deb..eca1a721 100644 --- a/math/fcos.glsl +++ b/math/fcos.glsl @@ -9,8 +9,7 @@ use: fcos( value) #ifndef FNC_FCOS #define FNC_FCOS -float fcos(in float x) -{ +float fcos(in float x){ float w = fwidth(x); return cos(x) * smoothstep( TWO_PI, 0.0, w ); } diff --git a/math/fcos.hlsl b/math/fcos.hlsl index 5b8b5fb3..8405b519 100644 --- a/math/fcos.hlsl +++ b/math/fcos.hlsl @@ -9,8 +9,7 @@ use: fcos( value) #ifndef FNC_FCOS #define FNC_FCOS -float fcos(in float x) -{ +float fcos(in float x){ float w = fwidth(x); return cos(x) * smoothstep( TWO_PI, 0.0, w ); }