//The isosurfaces and height fields isosurfaces

#declare ImageMapsScale = < 2.02, 1, 2.02 > ;
#declare ChasmMiddleRatio = 2255 / 4096;
#declare BoxPitFallPos = 0.03;//( ChasmMiddleRatio - 0.5 ) * ImageMapsScale.z;
#declare InOutBox = box{ < BoxPitFallPos, -2, BoxPitFallPos >, < -2 * ImageMapsScale.x, 2, -2 * ImageMapsScale.z > }
#declare PitFallInterval = 0.03;
#declare WrinklesPig = pigment{ wrinkles }
#declare NullColor = color srgb 0;
#declare GradScale = 2.1;

#declare PlaneFunc = function{ y }

#declare HillGradientPig = pigment{ gradient z color_map{ 
													[ 0 color srgb 0 ]
													[ (BoxPitFallPos + 0.5) - PitFallInterval color srgb 0 ]
													[ 1 color srgb 1 ]
											}
							scale < 1, 1, 2.2 >
							translate -z * 2.2 / 2
						}
#declare SlopePig = pigment{ average pigment_map{ 	[ 1.0 HillGradientPig ]
													[ 1.0 HillGradientPig rotate 90 * y ]  
									} 
					}
#declare SlopeFunc = function{ pigment{ SlopePig } }

#declare Z_HillFunc = function{ pigment{ HillGradientPig } }

#declare X_HillFunc = function{ pigment{ HillGradientPig rotate 90 * y } }

//Debugging box (leave commented if not debugging )
//object{ InOutBox translate -2.25 * y pigment{ color srgb < 1, 1, 0 > } }

#declare WrinklesPattern = function{ pattern{ wrinkles } }

#declare WrinklesGradPig = pigment{ gradient z pigment_map{ 	[ 0 NullColor ]
														[ (BoxPitFallPos + 0.5) - PitFallInterval NullColor ]
														[ (BoxPitFallPos + 0.5) + PitFallInterval WrinklesPig ]
														[ 1 WrinklesPig ]
										}
						scale < 1, 1, GradScale > translate -z * GradScale / 2 
					}

#declare AverageGradPig = pigment{ average pigment_map{ [ 1.0 WrinklesGradPig ][ 1.0 WrinklesGradPig rotate 90 * y ] } } 
					
#declare AverageWrinklesFunc = function{ pigment{ AverageGradPig } }					

#declare YGradTextureScale = 2.1;
