/* displacement map based on color information from a texture */ /* file */ displacement mapper1(float Km = 0.1, redchannel = 0; string texname = "") { float hump1 = 0, hump2 = 1 , red, green, blue; /* Breaks the texture file into separate rgb channels */ red = texture(texname[0]); green = texture(texname[1]); blue = texture(texname[2]); normal n = normalize(N); /* this tests for the amount of red within each pixel and then */ /* "bumps" accordingly. */ if(red >= redchannel && green >= 0 && blue >= 0) hump1 = 1; /* this tests for white values and doesn't allow for it tp "bump" */ if(red == 1.0 && green == 1.0 && blue == 1.0) hump2 = 0; /* multiples all of the hump values together and either bumps or */ /* doesn't */ P = P - n * hump1 * hump2 * Km; N = calculatenormal(P); }