Use hg_sdf

This commit is contained in:
Emmanuel BENOîT 2017-10-05 20:41:57 +02:00
parent 1df2a90dd8
commit c33efde305

View file

@ -44,24 +44,15 @@ void mapMaterial(
tIndex = 0; tIndex = 0;
} }
float box( vec3 p , vec3 sz )
{
vec3 n = abs( p ) - sz;
return max( max( n.x , n.y ) , n.z );
}
vec2 RM_Map( vec3 pos ) vec2 RM_Map( vec3 pos )
{ {
pos = pos - vec3( 0 , 0 , 0 );
vec3 q = pos; vec3 q = pos;
q.xy = mod( q.xy + 4. , 8. ) - 4.; HG_pMod2( q.xy , vec2( 8. ) );
q.xz *= mat2( HG_pR( q.xz , 1 );
cos( 1 ) , -sin(1) , return vec2( mix( HG_fBox( q , vec3( 1.5 ) ) ,
sin( 1 ) , cos( 1 ) ); HG_fSphere( q , 1.5 ) ,
return vec2( mix( box( q , vec3( 1.5 ) ) ,
length( q ) - 1.5 ,
.35 ) , .35 ) ,
step( 0. , 3 - length( pos.xy ) ) ); step( 0. , -HG_fSphere( pos , 3 ) ) );
} }