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

19 lines
No EOL
474 B
Text

#include "../math/saturate.msl"
/*
contributors: Inigo Quiles
description: intersection operation of two SDFs
use: <float> opIntersection( <float> d1, <float> d2 [, <float> smooth_factor] )
*/
#ifndef FNC_OPINTERSECTION
#define FNC_OPINTERSECTION
float opIntersection( float d1, float d2 ) { return max(d1,d2); }
float opIntersection( float d1, float d2, float k ) {
float h = saturate( 0.5 - 0.5*(d2-d1)/k );
return mix( d2, d1, h ) + k*h*(1.0-h);
}
#endif