lygia
/sdf
/opIntersection
)intersection operation of two SDFs
Dependencies:
Use:
<float> opIntersection( in <float> d1, in <float> d2 [, <float> smooth_factor] )
#ifndef FNC_OPINTERSECTION
#define FNC_OPINTERSECTION
float opIntersection( float d1, float d2 ) { return max(d1,d2); }
Material opIntersection(Material d1, Material d2) {
if (d1.sdf > d2.sdf){
return d1;
} else {
return 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
Dependencies:
Use:
<float> opIntersection( in <float> d1, in <float> d2 [, <float> smooth_factor] )
#ifndef FNC_OPINTERSECTION
#define FNC_OPINTERSECTION
float opIntersection( float d1, float d2 ) { return max(d1,d2); }
Material opIntersection(Material d1, Material d2)
{
if (d1.sdf > d2.sdf){
return d1;
} else {
return d2;
}
}
float opIntersection( 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
Dependencies:
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
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository