//A crater

#declare CraterPlaneFunc = function{ y }

#declare CylAccuracy = 100;

#declare CylinderFunc = 
function{
	pigment{ cylindrical 	color_map{
								#for( Index, 0, 0.4, 1 / CylAccuracy )
									[ Index color srgb 50 * Index * Index / 16 + 5 * Index / 4]
								#end
									[ 0.4 + 1 / CylAccuracy color srgb 1 ]
								#for( Index, 0.4 + 2 / CylAccuracy, 1, 1 / CylAccuracy )
									[Index color srgb 25 * ( Index * Index - 2 * Index + 1 ) / 9 ]
								#end
							}
		warp{ turbulence < 0.05, 1, 0.05> }
	}
}

#declare CircleDamagePig =
function{
	pigment{ cylindrical pigment_map{
								[ 0 color srgb 0 ]
								[ 0.001 wrinkles ]
								[ 0.4 granite ]
								[ 0.6 wrinkles ]
								[ 1 wrinkles ]
							}
	}
}

#declare IsoCrater =
isosurface{
	function{
		CraterPlaneFunc(x,y,z)
		- CylinderFunc(x,y,z).gray * 0.15
		+ CircleDamagePig(x,y,z).gray * 0.15
	}
	max_gradient 5.598
    accuracy 0.0025
    contained_by{ sphere{ 0, 1 - 0.002 } }
    pigment{ PlanetColor }
}