#macro read_image(filei,sizel,sizeh) #declare cpx = sizel/2; #declare cpy = sizeh/2; #declare sizel2 = sizel; #declare sizeh2 = sizeh; #declare map = pigment { image_map {tga filei} scale } box { <0,0,0.000000000001>, pigment {map} finish {ambient 1 specular 0 phong 0 diffuse 0} } #declare pixel = array[sizel][sizeh] //enregistrement pixels #declare py = 0; #while(py <= sizeh-1) #declare px = 0; #while(px <= sizel-1) #declare pixel[px][py] = eval_pigment(pigment{map},); #declare px = px+1; #end #declare py = py+1; #end #declare pixelold = pixel #end #macro read_depth(filedi) #declare depthactiv = 1; #declare mapd = pigment { image_map {tga filedi} scale } box { <0,0,2>, pigment {mapd} finish {ambient 1 specular 0 phong 0 diffuse 0} } #declare pixeld = array[sizel2][sizeh2] //enregistrement pixels #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare pixeld[px][py] = eval_pigment(pigment{mapd},); #declare px = px+1; #end #declare py = py+1; #end #end #macro render_image(methode) //creation des pixels #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #if(methode = 1) #if(pixel[px][py].x != pixelold[px][py].x | pixel[px][py].y != pixelold[px][py].y | pixel[px][py].z != pixelold[px][py].z) box { , pigment {color rgb pixel[px][py]} finish {ambient 1 diffuse 0 phong 0 specular 0} } #end #else box { , pigment {color rgb pixel[px][py]} finish {ambient 1 diffuse 0 phong 0 specular 0} } #end #declare px = px + 1; #end #declare py = py+1; #end camera { orthographic location look_at right (sizel2 - 1) * x up (sizeh2 - 1) * y } #end #macro filter_inverse() #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare pixel[px][py] = 1 - pixel[px][py]; #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_color(couleur) #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #switch(couleur) #case(0) #declare pixel[px][py] = pixel[px][py] * <1,0,0>; #break #case(1) #declare pixel[px][py] = pixel[px][py] * <0,1,0>; #break #case(2) #declare pixel[px][py] = pixel[px][py] * <0,0,1>; #break #end #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_grayscale() #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare moyenne = (pixel[px][py].x + pixel[px][py].y + pixel[px][py].z) / 3; #declare pixel[px][py] = ; #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_tvlines(mode,linecolor) #declare flag = mode; #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #if(flag = 1) #declare pixel[px][py] = linecolor; #end #declare px = px+1; #end #if(flag = 0) #declare flag = 1; #else #declare flag = 0; #end #declare py = py+1; #end #end #macro filter_fliph() #declare pixel2 = pixel #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare pixel[px][py] = pixel2[px][sizeh2-1-py]; #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_flipv() #declare pixel2 = pixel #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare pixel[px][py] = pixel2[sizel2-1-px][py]; #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_brightness(taux) #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #declare pixel[px][py] = pixel[px][py] + (taux / 2); #declare px = px + 1; #end #declare py = py + 1; #end #end #macro filter_contrast(taux) #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #declare pixel[px][py] = pixel[px][py] * (taux + 1); #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_colorreplace(col1,col2,tolerance) #declare py = 0; #while(py <= sizeh2-1) #declare px = 0; #while(px <= sizel2-1) #if(abs(pixel[px][py].x - col1.x) <= tolerance & abs(pixel[px][py].y - col1.y) <= tolerance & abs(pixel[px][py].z-col1.z) <= tolerance) #declare pixel[px][py] = col2; #end #declare px = px+1; #end #declare py = py+1; #end #end #macro filter_noise(taux) #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #declare r1 = seed(px * (tick_count + 1)); #declare p1 = (rand(r1) * 2 - 1) * taux; #declare r2 = seed(py * (3 * p1 * (tick_count + 3))); #declare p2 = (rand(r2) * 2 - 1) * taux; #declare r3 = seed(px + py * (p2 * tick_count + 120)); #declare p3 = (rand(r3) * 2 - 1) * taux; #declare pixel[px][py] = pixel[px][py] + ; #declare px = px + 1; #end #declare py = py + 1; #end #end #macro filter_blur(taux) #declare pixel2 = pixel #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #if(px > 0 & px < sizel2-1 & py < sizeh2 - 1 & py > 0) #declare pixel[px][py] = (pixel2[px - 1][py - 1] + pixel2[px - 1][py] + pixel2[px - 1][py + 1] + pixel2[px][py + 1] + pixel2[px + 1][py + 1] + pixel2[px + 1][py] + pixel2[px + 1][py - 1] + pixel2[px][py - 1] + pixel2[px][py] * (1.0 / taux)) / (8.0 + (1.0 / taux)); #end #declare px = px+1; #end #declare py = py + 1; #end #end #macro filter_sinusv(taille,taux,offs) #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #declare pixel[px][py] = pixel[px][py] * taux * (sin(px * (1.0 / taille) * 0.1) + 1 + offs); #declare px = px + 1; #end #declare py = py + 1; #end #end #macro filter_vaguesv(freq,force) #declare pixel2 = pixel #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #if(px - force * sin(py * freq / 2.0) <= sizel2 - 1 & px - force * sin(py * freq / 2.0) >= 0) #declare pixel[px][py] = pixel2[px - force * sin(py * freq / 2.0)][py]; #end #declare px = px + 1; #end #declare py = py + 1; #end #end #macro filter_vaguesh(freq,force) #declare pixel2 = pixel #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #if(py - force * sin(px * freq / 2.0) <= sizeh2 - 1 & py - force * sin(px * freq / 2.0) >= 0) #declare pixel[px][py] = pixel2[px][py - force * sin(px * freq / 2.0)]; #end #declare px = px + 1; #end #declare py = py + 1; #end #end #macro filter_fog(taux) #declare py = 0; #while(py <= sizeh2 - 1) #declare px = 0; #while(px <= sizel2 - 1) #declare pixel[px][py] = pixel[px][py] + taux * (1 - pixeld[px][py]); #declare px = px + 1; #end #declare py = py + 1; #end #end