// xs_begin
// author : '@mode_vis'
// arg : {id = '0' name = 'Radius' value = '3'   range = '1 128'    step = '1'    decimal = '0' }
// 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

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