/* FixSeams.pov 2011 Samuel Benge This file will fill pure black areas of a texture with neigh- boring pixels. It's to be used on troublesome textures (applied to meshes) that exhibit black seams between regions. It will fix all black seams. Don't use antialising on the input image, or the image created by this file during your rendering process. Any sort of smoothing will counteract the benefits given by this file. Only use AA/ interpolation/focal blur on the final result! The two editable parameters are these: #1 padding (float value) This is how many pixels to pad around the "solid" areas of the texture. Keep it at or above 2. #2 your input image This is the input image that you intend to use. With a padding value of 2, one render pass is usually suffi- cient, but in some cases (lower image resolutions, for instance) you may need to render this file one or more times to get rid of all visible seams. */ #version 3.7; /*ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/ /* Begin Editable Params */ /* editable parameter #1: padding */ #declare Padding = 2; #declare Img = pigment{ image_map{ /* editable parameter #2: your input image */ png "Prox.png" } translate -(x+y)/2 scale 2 } /* End Editable Params */ /*_____________________*/ // making the image pigment into a function #local FImg = function{ pigment{ Img } } // the kernel is a series of samples to be evaluated #local Kernel = array[9]{ <0,0>, <-1,0>, <1,0>, <0,-1>, <0,1>, <-1,-1>, <1,-1>, <-1,1>, <1,1> } // this macro just switches between color channels #macro Chan(Channel) #switch(Channel)#case(0).x#break#case(1).y#break#case(2).z#break#end #end // pads non-black areas with neighboring pixels #macro PadImg(Channel) function{ select( // test against original image max(0,min(1,FImg(x,y,0)Chan(Channel)))-0.00001, // if an area is black, pad the image max( 0 #for(V,0,dimension_size(Kernel,1)-1) #local X = Kernel[V].x*(Padding/image_width); #local Y = Kernel[V].y*(Padding/image_height); ,max(0,min(1,FImg(x+X,y+Y,0)Chan(Channel))) #end ), // otherwise leave the image unchanged max(0,min(1,FImg(x,y,0)Chan(Channel))) ) } #end // the visible texture plane{z,0 pigment{ #if(0) Img #else average pigment_map{ [1 PadImg(0) color_map{[0 rgb 0][1 rgb x*3]}] [1 PadImg(1) color_map{[0 rgb 0][1 rgb y*3]}] [1 PadImg(2) color_map{[0 rgb 0][1 rgb z*3]}] } #end } finish{ambient 1} } // ... global_settings{assumed_gamma 1.0} camera{ orthographic right x*2 up y*2 location -z*2 look_at 0 }