POV-Ray : Newsgroups : povray.advanced-users : isosurface and trace problem : isosurface and trace problem Server Time
6 May 2024 05:10:20 EDT (-0400)
  isosurface and trace problem  
From: Doctor John
Date: 16 Jun 2009 13:30:04
Message: <4a37d69c@news.povray.org>
I'm having a problem with getting trace to accurately place objects on
an isosurface. I'm sure I'm making an elementary mistake but I've been
staring at the code so long that I think I've gone error-blind :-)

OK First the isosurface section:

#declare Sand = texture {
	pigment {
		color rgb <0.9, 0.7, 0.3>*2
	 }
	finish {
		specular 0.6
		diffuse 0.4
	}
	normal {
		granite 0.15
		scale 0.05
	}
}

#declare FPigment = function{
	pigment {
		bozo
		color_map {
			[0.0 color rgb 0.0]
			[0.3 color rgb 0.2]
			[0.7 color rgb 0.8]
			[1.0 color rgb 1.0]
		}
		warp {
			turbulence 0.01
		}
		scale <2, 3, 2>
		translate <1.8, -6.7, 0>
	}
}

#declare Terrain_Obj = isosurface {
	function { y-FPigment(x, 0, -z).gray*0.4 }
	max_gradient 1.024
	accuracy 0.01
	contained_by {
		box {
			<-10000, -0.1, -10000>, <10000, 0.41, 10000>
		}
	 }
}

object {
	Terrain_Obj
	texture { Sand scale 1.4}
	scale <3, 3.1, 1>
	translate <0, -0.65, 0>
	rotate y*45
}

...and now the trace bit:

#declare Grain = sphere {0, 0.01}
#declare Count = 0;
#declare Norm = <0, 0, 0>;
#declare Spacing = 0.1;
#declare Seed = seed(54321);
#declare PosX = -25;

#while (PosX < 25)
	#declare PosZ = -8;
	#while (PosZ < 10)
		#declare Norm = <0, 0, 0>;
		#declare Start = <PosX+(rand(Seed)-0.5)*Spacing, 3.0,
PosZ+(rand(Seed)-0.5)*Spacing>;
		#declare Pos = trace (Terrain_Obj, Start, -y, Norm );
		#if (vlength(Norm) != 0)
			object {
				Grain
				texture {Sand}
				translate Pos
			}
			#declare Count = Count+1; //used later in a #debug
		#end
		#declare PosZ = PosZ + Spacing;
	#end
	#declare PosX = PosX + Spacing;
#end

When I render the image the spheres are definitely not coincident with
the isosurface, in fact they seem to be following a completely different
shape. I'm also getting unexplained gaps in the pattern of the spheres
almost as if they're only being placed on a particular range of slopes.

Any ideas?

John (feeling particularly stupid)
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

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