// xs_begin
// src : 'https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm'
// arg : {id = '0' name = 'Radius' value = '5'   range = '0 64'    step = '0.1'    decimal = '1' }
// xs_end

//===== user args =====
// uniform float	i_args[8];

//===== built-in args =====
// uniform vec3		i_volume_size;	// volume size [1-256]
// uniform float	i_color_index;	// color index [0-255]
// uniform vec3		i_mirror;		// mirror mode [0,1]
// uniform vec3		i_axis;			// axis mode [0,1]
// uniform float	i_iter;			// iteration index

//===== built-in functions ===== 
// float voxel( vec3 v );			// get voxel color index at position v

float map( vec3 v ) {				// generate a new voxel color index at position v ( v is at the center of voxel, such as vec3( 1.5, 2.5, 4.5 ) )
	float r = i_args[0];
	v -= i_volume_size * 0.5;
	vec3 q = abs(v) - i_volume_size * 0.5 + r;
	if ( length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) < r ) {
		return i_color_index;
	}
	return 0.0;
}
