POV-Ray : Newsgroups : povray.general : Blob functions help : Re: Blob functions help Server Time
30 Jul 2024 02:27:50 EDT (-0400)
  Re: Blob functions help  
From: SharkD
Date: 30 Jan 2010 22:33:32
Message: <4b64fa0c@news.povray.org>
Here are the POV-Ray versions of the formulas I'm using:

#switch (Blob_method)
	// GameDev.net tutorial
	#case (1)
		#declare Blob_threshold_1 = 3;
		#declare Blob_threshold_2 = 3;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.5;
		#declare fn_A = function { Blob_radius / sqrt(pow(x+Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_B = function { Blob_radius / sqrt(pow(x-Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };
	#break
	// POV-Ray isosurface tutorial
	#case (2)
		#declare Blob_strength  = 0.5;
		#declare Blob_threshold = 1;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.5;
		#declare fn_A = function { pow(x+Blob_distance,2) + pow(y,2) + 
pow(z,2) - pow(Blob_radius,2) };
		#declare fn_B = function { pow(x-Blob_distance,2) + pow(y,2) + 
pow(z,2) - pow(Blob_radius,2) };
		#declare fn_C = function { Blob_strength + 1 }
		#declare fn_D = function { pow(Blob_strength, fn_A(x,y,z)) + 
pow(Blob_strength, fn_B(x,y,z)) - fn_C(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_D(x,y,z)) };
	#break
	// POV-Ray blob tutorial
	#case (3)
		#declare Blob_strength  = 3;
		#declare Blob_threshold = 1;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2;
		#declare fn_A = function { min(sqrt(pow(x+Blob_distance,2) + pow(y,2) 
+ pow(z,2)), Blob_radius) };
		#declare fn_B = function { min(sqrt(pow(x-Blob_distance,2) + pow(y,2) 
+ pow(z,2)), Blob_radius) };
		#declare fn_C = function { Blob_strength * pow(1 - pow(fn_A(x,y,z) / 
Blob_radius, 2), 2) };
		#declare fn_D = function { Blob_strength * pow(1 - pow(fn_B(x,y,z) / 
Blob_radius, 2), 2) };
		#declare fn_G = function { fn_C(x,y,z) + fn_D(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_G(x,y,z)) };
	#break
	// Wikipedia
	#case (4)
		#declare Blob_threshold_1 = 2;
		#declare Blob_threshold_2 = 4;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.75;
		#declare fn_A = function { Blob_radius / (pow(x+Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_B = function { Blob_radius / (pow(x-Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };
	#break
	// GameDev.net tutorial, diamond
	#case (5)
		#declare Blob_threshold_1 = 2;
		#declare Blob_threshold_2 = 3;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.75;
		#declare fn_A = function { Blob_radius / (abs(x+Blob_distance) + 
abs(y) + abs(z)) };
		#declare fn_B = function { Blob_radius / (abs(x-Blob_distance) + 
abs(y) + abs(z)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };;
	#break
	// isosurface tutorial, diamond
	#case (6)
		#declare Blob_strength  = 0.5;
		#declare Blob_threshold = 0;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 3;
		#declare fn_A = function { (abs(x+Blob_distance) + abs(y) + abs(z) - 
Blob_radius) / pow(Scene_scale,2) };
		#declare fn_B = function { (abs(x-Blob_distance) + abs(y) + abs(z) - 
Blob_radius) / pow(Scene_scale,2) };
		#declare fn_C = function { Blob_strength + 1 }
		#declare fn_D = function { pow(Blob_strength, fn_A(x,y,z)) + 
pow(Blob_strength, fn_B(x,y,z)) - fn_C(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_D(x,y,z)) };
	#break
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.