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

17 lines
No EOL
446 B
HLSL

/*
contributors: Inigo Quiles
description: Substraction operation of two SDFs
use: <float> opSubstraction( in <float> d1, in <float> d2 [, <float> smooth_factor])
*/
#ifndef FNC_OPSUBSTRACTION
#define FNC_OPSUBSTRACTION
float opSubtraction( float d1, float d2 ) { return max(-d1,d2); }
float opSubtraction( float d1, float d2, float k ) {
float h = saturate( 0.5 - 0.5*(d2+d1)/k );
return lerp( d2, -d1, h ) + k*h*(1.0-h);
}
#endif