This repository has been archived on 2024-12-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2024CG-project-render/glsl/smooth_heaviside.glsl
github-classroom[bot] 686dcaf351
Initial commit
2024-11-29 09:50:03 +00:00

13 lines
438 B
GLSL

// A useful filter, behaves like a smoothly parameterized smooth Heaviside
// function.
//
// Inputs:
// x input scalar (-inf, inf)
// t control steepness of step function: --> 0 more linear, --> inf more like
// Heaviside function (piecewise constant function x<0--> -1 , x>0 --> 1)
// Returns scalar value
float smooth_heaviside( float x, float t)
{
return (1./(1.+exp(-2.*t*(x)))-1./2.)/(1./(1.+exp(-2.*t*1.))-1./2.);
}