24 lines
470 B
Text
24 lines
470 B
Text
/*
|
|
contributors: Inigo Quiles
|
|
description: elongate operation of two SDFs
|
|
use: <float4> opElongate( <float3> p, <float3> h )
|
|
*/
|
|
|
|
#ifndef FNC_OPELONGATE
|
|
#define FNC_OPELONGATE
|
|
|
|
float2 opElongate( float2 p, float2 h ) {
|
|
return p-clamp(p,-h,h);
|
|
}
|
|
|
|
float3 opElongate( float3 p, float3 h ) {
|
|
return p-clamp(p,-h,h);
|
|
}
|
|
|
|
float4 opElongate( float4 p, float4 h ) {
|
|
float3 q = abs(p)-h;
|
|
return float4( max(q,0.0), min(max(q.x,max(q.y,q.z)), 0.0) );
|
|
}
|
|
|
|
#endif
|
|
|