#macro HexToDecimal (HexString) #local D0 = asc (strupr (substr (HexString, 1, 1))); #local D1 = asc (strupr (substr (HexString, 2, 1))); #switch (D0) #range (asc ("A"), asc ("F")) #declare Decimal = (D0 - asc ("A") + 10) * 16; #break #range (asc ("0"), asc ("9")) #declare Decimal = (D0 - asc ("0")) * 16; #break #else #error "\nIllegal hex value.\n\n") #break #end //#switch #switch (D1) #range (asc ("A"), asc ("F")) #declare Decimal = Decimal + D1 - asc ("A") + 10; #break #range (asc ("0"), asc ("9")) #declare Decimal = Decimal + D1 - asc ("0"); #break #else #error "\nIllegal hex value.\n\n") #break #end //#switch Decimal; #end //#macro HexToDecimal #macro HexToRGB (HexValue) #local R = HexToDecimal (substr (HexValue, 1, 2)); #local G = HexToDecimal (substr (HexValue, 3, 2)); #local B = HexToDecimal (substr (HexValue, 5, 2)); / 255 #end //#macro HexToRGB /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #local Randomizer_Stone = seed (0); //Changing the seed value will re-order the stone layers and change the brightness of the veins. #local NGraniteColorPairs = 8; //Set this variable according to how many color pairs are defined below. #local NGraniteColors = NGraniteColorPairs * 2; #local GraniteColor_Hex = array [NGraniteColors] { //These are the color pairs. "6F4B4D", //Orange "9A786F", //Orange "63544F", //Pink "966F70", //Pink "887B73", //Pink/Brown //Darken "564239", //Pink/Brown "524A3F", //Green/Grey //Saturate "878076", //Green/Grey "AC9D96", //Brown "685B53", //Brown "887B73", //Brown "A99C94", //Brown "402E2A", //Brown "63544F", //Brown "51443C", //Brown "6D5E59" //Brown } //array #local GraniteColor = array [NGraniteColors] #for (I, 0, NGraniteColors - 1) #local Temp = HexToRGB (GraniteColor_Hex [I]); #local GraniteColor [I] = color Temp; //This is all that's really necessary. #local GraniteColor [I] = color Temp - White * .05 - Blue * .05; #if (I > 5) #local GraniteColor [I] = color GraniteColor [I] + Red * .01; #end //#if #end //#for #local GraniteColor [4] = color GraniteColor [4] * .3; #local GraniteColor [5] = color GraniteColor [5] * .3; #local GraniteColor [6] = color GraniteColor [6] - White * .15; #local GraniteColor [7] = color GraniteColor [7] - White * .15; #local NLayers = 100; #local StoneLayerTexture = array [NLayers] /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // Make the stone texture #for (I, 0, NLayers - 1) #local StoneLayerTexture [I] = texture { pigment { cells turbulence 2 color_map { #local WhichGraniteColor = int (rand (Randomizer_Stone) * NGraniteColorPairs) * 2; #local WhiteLevel = 0; #local TransparencyLevel0 = .4; #local TransparencyLevel1 = .7; [0, .1 color GraniteColor [WhichGraniteColor] transmit TransparencyLevel0 color GraniteColor [WhichGraniteColor + 1] transmit TransparencyLevel1] [.1, .2 color GraniteColor [WhichGraniteColor + 1] transmit TransparencyLevel1 color rgbt ] [.2, 1 color rgbt color rgbt ] } //color_map } //pigment #local S = .4; scale translate (rand (Randomizer_Stone) * 1000000) * z } //texture #end //#for #declare StoneColor = texture { //Base layer pigment { bozo turbulence 2 color_map { #for (I, 0, NGraniteColors - 1) [I / (NGraniteColors - 1) GraniteColor [I]] #end //#for } //color_map } //pigment #local S = 1; scale translate (rand (Randomizer_Stone) * 1000000) * z } //texture #for (I, 0, NLayers - 1) #declare StoneColor = texture {StoneColor} texture {StoneLayerTexture [I]} #end //#for #local Dots = texture { pigment { granite turbulence 2 color_map { #local TransparencyLevel = .6; [0 color Black transmit 1] [.1 color Black transmit TransparencyLevel] [.2 color Black transmit TransparencyLevel] [.3 color Black transmit 1] [1 color Black transmit 1] } //color_map } //pigment #local S = .1; scale } //texture #declare StoneColor = texture {StoneColor} texture {Dots} #local S = .2; #declare StoneColor = texture {StoneColor finish {reflection .32 phong .1 phong_size 90} normal {granite .025 scale }} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // Make the vein texture #local WhichColorPair = 6; //Select one of the color pairs to brighten #local VeinBrightnessFactor = 7; //Set this variable #local GraniteColor [WhichColorPair * 2] = color GraniteColor [WhichColorPair * 2] * VeinBrightnessFactor; #local GraniteColor [WhichColorPair * 2 + 1] = color GraniteColor [WhichColorPair * 2 + 1] * VeinBrightnessFactor; #for (I, 0, NLayers - 1) #local StoneLayerTexture [I] = texture { pigment { cells turbulence 2 color_map { #local WhichGraniteColor = int (rand (Randomizer_Stone) * NGraniteColorPairs) * 2; #local WhiteLevel = 1; #local TransparencyLevel0 = .4; #local TransparencyLevel1 = .7; [0, .1 color GraniteColor [WhichGraniteColor] transmit TransparencyLevel0 color GraniteColor [WhichGraniteColor + 1] transmit TransparencyLevel1] [.1, .2 color GraniteColor [WhichGraniteColor + 1] transmit TransparencyLevel1 color rgbt ] [.2, 1 color rgbt color rgbt ] } //color_map } //pigment #local S = .4; scale translate (rand (Randomizer_Stone) * 1000000) * z } //texture #end //#for #declare VeinColor = texture { //Base layer pigment { bozo turbulence 2 color_map { #for (I, 0, NGraniteColors - 1) [I / (NGraniteColors - 1) GraniteColor [I]] #end //#for } //color_map } //pigment #local S = 1; scale translate (rand (Randomizer_Stone) * 1000000) * z } //texture #for (I, 0, NLayers - 1) #declare VeinColor = texture {VeinColor} texture {StoneLayerTexture [I]} #end //#for #local S = .6; #declare VeinColor = texture {VeinColor finish {reflection .32 phong .1 phong_size 90} scale }