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

18 lines
No EOL
918 B
Text

/*
contributors: Patricio Gonzalez Vivo
description: gaussian coeficient
use: <float4|float3|float2|float> gaussian(<float> sigma, <float4|float3|float2|float> d)
examples:
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/math_gaussian.frag
license:
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
*/
#ifndef FNC_GAUSSIAN
#define FNC_GAUSSIAN
float gaussian(float d, float s) { return exp(-(d*d) / (2.0 * s*s)); }
float gaussian( float2 d, float s) { return exp(-( d.x*d.x + d.y*d.y) / (2.0 * s*s)); }
float gaussian( float3 d, float s) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z ) / (2.0 * s*s)); }
float gaussian( float4 d, float s) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z + d.w*d.w ) / (2.0 * s*s)); }
#endif