// PoVRay 3.7 Scene File "TdG_PaintPeeling.mcr" // author: Thomas de Groot // date: May 2014 // version: 2 // restrictions: no restrictions /*============================================================================= Description: Macro for simulating a crackled and peeling paint surface. Usage: Two instances of an object should be used, one for the underlying texture, the other - slightly scaled up - for the paint itself. The macro obeys to the following parameters: - Pattern : 1 = granite pattern; 2 = agate pattern; 3 = a declared pigment_pattern (PP). - P_paint : the pigment to use for the paint. - T_scale : the final scale of the paint texture. - PeelFactor : [0 - 1] controls how much paint peels away. - CrackFactor : controls the amount of cracking. - CrackWidth : controls the width of the cracks. Example: #declare Plaster = texture { pigment { granite color_map { [0.4 srgb <0.9, 0.9, 0.8>] [1.0 srgb <0.5, 0.5, 0.4>] } scale 1.0 } normal { granite 0.2 slope_map { [0.00 <0.2, 1>] [0.25 <0.3, 0>] [0.50 <0.2,-1>] [0.75 <0.0, 0>] [1.00 <0.2, 1>] } scale 0.1 } finish {diffuse 0.8} } #declare DeepRed = pigment { granite color_map { [0 srgb <0.8, 0.1, 0.2>] [1 srgb <0.6, 0.1, 0.2>] } } //when using Pattern=3 #declare PP = pigment { wrinkles color_map { [0.0 rgb 0] [1.0 rgb 1] } scale 0.2 } union { superellipsoid {<0.1, 0.1> texture {Plaster} } superellipsoid {<0.1, 0.1> scale 1.003 PaintPeeling(1, DeepRed, 1.5, 0.2, 0.2, 0.07) } rotate <0, 20, 0> translate <0, 1, 0> } =============================================================================*/ #macro PaintPeeling(Pattern, P_paint, T_scale, PeelFactor, CrackFactor, CrackWidth) #local N_cracks = normal { crackle solid slope_map { [0 < 0, 1> ] [0.06 < 1, 1> ] [0.06 < 1, -1> ] [1 < 0, -1> ] } scale 0.01 } #local Crack = texture { pigment { crackle turbulence .15 pigment_map { [0.00 srgbt <1,1,1,1> ] [0.04 srgbt <1,1,1,1> ] [0.04 P_paint ] } } normal { crackle solid slope_map { [0 < 0, 1> ] [0.06 < 1, 1> ] [0.06 < 1, -1> ] [1 < 0, -1> ] } scale 0.1 } finish {diffuse 0.8} scale CrackWidth } #local Cracking = PeelFactor + CrackFactor; #if (Cracking > 1.00) #local Cracking = 1.0; #end texture { #switch (Pattern) #case (1) granite #break #case (2) agate #break #case (3) pigment_pattern {PP} #end texture_map { [PeelFactor pigment {srgbt <1,1,1,1>}] //no paint [PeelFactor Crack] [Cracking Crack] [Cracking P_paint finish {diffuse 0.8} normal {N_cracks}] //full paint } scale T_scale } #end //of macro