/* ElevationLines.pov 2012 Sam Benge Recommended command line options for this scene: +a0.3 +am1 +r3 +w512 +h512 The Macro Pg_Elevation_Lines(PgInput, NLines, LineSize, Quality, LineOffs, LineSmoothing) PgInput: height data, a pigment NLines: the number of elevation lines to draw (1.0-?.f) LineSize: desired line size (in pixels)(1.0-?.f) Quality: line quality (0-?)(8 is usually good) LineOffs: line offset (phase)(0.0-1.0) LineSmoothing: smooth the lines or not (on/off) Calculating the number of lines needed for your map is completely up to you. (Hint: you can use decimal values.) Larger lines sizes will take longer to render; it's pretty much unavoidable unless you don't mind lowering the quality. */ #version 3.7; global_settings{assumed_gamma 1.0} #default{ finish{ ambient 1 } } camera{ orthographic right x*2 up y*2 location -z look_at 0 } // a macro for drawing elevation lines from an input image // returns a pigment_pattern // parameter details are given below #macro Pg_Elevation_Lines(PgInput, NLines, LineSize, Quality, LineOffs, LineSmoothing) #local Quality = max(1, int(Quality*LineSize)); // The Fermat Spiral #macro SampleLoop(Param) max( 0 #for(N, 1, Quality) #local C = 1/Quality*N; #local R = pow(C*sqrt(N)/pow(Quality,.5),1/3); #local Angle = N*137.508; #local Pt = vrotate(y*R, z*Angle); #local PtX = Pt.x*LineSizeX; #local PtY = Pt.y*LineSizeY; #if(Param) , (1-R*LineSmoothing)*(1-FInput(x+PtX, y+PtY, 0)) #else , (1-R*LineSmoothing)*FInput(x+PtX, y+PtY, 0) #end #end ) #end #local FInput = function{ pattern{ pigment_pattern{ PgInput phase 1-LineOffs/2 frequency NLines/2 color_map{ [.5 rgb 0] [.5 rgb 1] } } } } pigment_pattern{ #local LineSizeX = LineSize/image_width; #local LineSizeY = LineSize/image_height; function{ SampleLoop(1)*(FInput(x, y, 0)=1) + SampleLoop(0)*(FInput(x, y, 0)=0) } cubic_wave warp{planar} } #end // Pg_Elevation_Lines // demonstration plane{z, 0 // height data #declare InputPigment = pigment{ cylindrical rotate x*90 turbulence .35 scale .85 } pigment{ Pg_Elevation_Lines( InputPigment, 8, // number of elevation lines (1.0-?.f) 3, // line size in pixels (1.0-?.f) 8, // quality (0-?)(it is transformed to quality*LineSize inside the macro) 0, // line offset (phase)(0.0-1.0) off // line smoothing/blending (on or off) ) pigment_map{[0 InputPigment][1 rgb x]} } }