// Macros that define textures given a color and other parameters // Last edited on 2024-05-01 12:25:07 by stolfi #macro texture_metal(rgb_self,rgb_refl,wt_black,wt_white,wt_refl,mag) // Metal texture with diffuse color {rgb_self}, mirror color {rgb_refl}, // mirror strength {wt_refl}. // Both colors are mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; #local color_refl = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_refl; texture{ pigment{ color rgb color_self } normal{ granite 0.05 scale mag } finish{ ambient 0.15 diffuse 0.85 - wt_refl reflection wt_refl * color_refl specular 0.75 roughness 0.01 metallic brilliance 4 } } #end #macro texture_rock(rgb_self,wt_black,wt_white,mag) // Rock texture with diffuse color {rgb_self}. // Color is mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; texture{ pigment{ color rgb color_self } finish{ ambient 0.1 diffuse 0.9 specular 0.50 roughness 0.05 } normal { granite 0.30 scale mag } } #end #macro texture_plastic(rgb_self,rgb_refl,wt_black,wt_white) // Plastic texture with diffuse color {rgb_self} and polish color {rgb_refl}. // Both colors are mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; #local color_refl = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_refl; texture{ pigment{ color color_self } finish { diffuse 0.9 ambient 0.1 } } texture{ pigment{ color color_refl filter 1.00 } finish { diffuse 0.0 ambient 0.0 specular 0.30 roughness 0.01 } } #end #macro texture_matte(rgb_self,wt_black,wt_white) // Matte texture with diffuse color {rgb_self}. // Color is mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; texture{ pigment{ color rgb color_self } finish{ diffuse 0.9 ambient 0.1 } } #end #macro texture_foam(rgb_self,wt_black,wt_white) // Matte texture with diffuse+ambient color {rgb_self}. // Color is mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; texture{ pigment{ color rgb color_self } finish{ diffuse 0.8 ambient 0.2 brilliance 2 } } #end #macro texture_bulb(rgb_self,wt_black,wt_white) // Self-glowing texture with diffuse color {rgb_self}. // Color is mixed with {wt_black} of black and {wt_white} of white. #local color_self = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_self; texture{ pigment{ color rgb color_self } finish{ ambient 1 diffuse 0 reflection 0 specular 0 } } #end #macro texture_checker_tiles(rgb_tile_0,rgb_tile_1,wt_black,wt_white) // Checkerboard tile texture with tiles {rgb_self}. // Color is mixed with {wt_black} of black and {wt_white} of white. #local color_tile_0 = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_tile_0; #local color_tile_1 = wt_white * < 1,1,1 > + (1 - wt_white - wt_black) * rgb_tile_1; texture{ pigment{ checker color rgb_color_0, color rgb_color_1 } finish{ diffuse 0.9 ambient 0.1 } } texture{ pigment{ color <1,1,1> filter 0.90 } finish { diffuse 0.0 ambient 0.0 specular 0.30 roughness 0.01 } } #end