#version 3.6; #include "strings.inc" global_settings { assumed_gamma 1.0 } // ---------------------------------------- camera { orthographic location <0,0,1> look_at <0,0,0> right (image_width/image_height)*x up 1*y } // ---------------------------------------- #macro DE_CreateVeneerPigment(NAME_STRING, WOOD_PATTERN_PIGMENT, WOOD_COLOR_MAP, VENEER_THICKNESS, VENEER_START, DEVIATION_FROM_CENTER) // NAME_STRING: string containing the name of the pigment it will be referenced by (eg. "my_veneer_pig") // WOOD_PATTERN_PIGMENT: a black white pigment, which will be used as base for the veneer pattern // WOOD_COLOR_MAP: the color_map for the resulting pigement // VENEER_THICKNESS: thickness of the veneer (increase of radius with one turn) .... ~1-5 // VENEER_START: minimal radius of the base material the veneer pattern is taken from ... try something around 150 // DEVIATION_FROM_CENTER: move the wood pattern slightly of center (gives a more natural look) // declare the names of the needed elements #local wood_pattern_fcn_name = concat(NAME_STRING,"_w_pattern_fcn"); #local veneer_pattern_fcn_name = concat(NAME_STRING,"_v_pattern_fcn"); // declare the wood pattern function based on the given pigment Parse_String(concat("#declare ",wood_pattern_fcn_name," =")) function { pigment { WOOD_PATTERN_PIGMENT translate x*DEVIATION_FROM_CENTER } } // declare the veneer pattern function based on the formely declared wood pattern function Parse_String(concat("#declare ",veneer_pattern_fcn_name," =")) function { Parse_String(wood_pattern_fcn_name)(VENEER_THICKNESS*(x+((y/VENEER_THICKNESS)-int(y/VENEER_THICKNESS)))*cos((x+((y/VENEER_THICKNESS)-int(y/VENEER_THICKNESS)))) ,VENEER_THICKNESS*(x+((y/VENEER_THICKNESS)-int(y/VENEER_THICKNESS)))*sin((x+((y/VENEER_THICKNESS)-int(y/VENEER_THICKNESS)))) ,z).gray } // declare the pigment based on the veneer pattern function Parse_String(concat("#declare ",NAME_STRING," =")) pigment { function { Parse_String(veneer_pattern_fcn_name)((x+VENEER_START)/(2*pi),y,z) } color_map { WOOD_COLOR_MAP } rotate x*90 } #end // < the wood pattern > #declare wood_cell_strc= pigment { crackle form <1,0,0> color_map { [0.0 color rgb 0.0] [0.5 color rgb 1.0] [1.0 color rgb 1.0] } scale <.08,.08,10>*.5 } #declare wood_ring_strc = pigment { wood color_map { [0.0 color rgb 0.0] [1.0 color rgb 1.0] } ramp_wave scale <5,5,3> warp { turbulence <1,1,3> octaves 5 lambda 1.3 omega .2 } scale <.2,.2, 1/3> scale .1 warp { turbulence <1,1,0>*.2 octaves 5 lambda 1.6 omega .1 } scale 10 } #declare wood_pattern= pigment { pigment_pattern { wood_cell_strc } pigment_map { [0 color rgb 0] [1 wood_ring_strc] } } // < the color_map > #declare my_color_map = color_map { [0.000000 color rgbt <0.840000, 0.658397, 0.372235, 0.000000>] [0.121123 color rgbt <0.884706, 0.776257, 0.463119, 0.000000>] [0.824225 color rgbt <0.929412, 0.894118, 0.554002, 0.000000>] [0.824225 color rgbt <0.929412, 0.894118, 0.554002, 0.000000>] [0.909897 color rgbt <0.884706, 0.776257, 0.463119, 0.000000>] [1.000000 color rgbt <0.840000, 0.658397, 0.372235, 0.000000>] } // < macro invocation > DE_CreateVeneerPigment("my_veneer_pig", wood_pattern, my_color_map, 1, 150, 10) // now we can refer to the pigement as box { <-0.5*(image_width/image_height), -0.5, 0>, <0.5*(image_width/image_height), 0.5, 0> // this box fits exactly in view texture { pigment { my_veneer_pig } finish { ambient 1 diffuse 0 } scale .03 } }