You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			25 lines
		
	
	
		
			983 B
		
	
	
	
		
			Plaintext
		
	
		
		
			
		
	
	
			25 lines
		
	
	
		
			983 B
		
	
	
	
		
			Plaintext
		
	
| 
											2 years ago
										 | // xs_begin | ||
|  | // src : 'https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm' | ||
|  | // arg : { var = 'm_radius' name = 'Radius' value = '5'   range = '0 64'    step = '0.1'    precision = '1' } | ||
|  | // xs_end | ||
|  | 
 | ||
|  | //===== built-in args ===== | ||
|  | // uniform vec3		i_volume_size;		// volume size [1-256] | ||
|  | // uniform float	i_color_index;		// current color index [0-255] | ||
|  | // uniform int		i_num_color_sels;	// number of color selections [1-255] | ||
|  | 
 | ||
|  | //===== built-in functions =====  | ||
|  | // float voxel( vec3 v );				// get voxel color index | ||
|  | // float color_sel( float k );			// get kth selected color index | ||
|  | // vec4 palette( float index );			// get palette color | ||
|  | 
 | ||
|  | // 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 ) { | ||
|  | 	v -= i_volume_size * 0.5; | ||
|  | 	vec3 q = abs(v) - i_volume_size * 0.5 + m_radius; | ||
|  | 	if ( length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) < m_radius ) { | ||
|  | 		return i_color_index; | ||
|  | 	} | ||
|  | 	return 0.0; | ||
|  | } |