/* basic blend texture shader. Allows the user to define and blend textures between */ /* the inside and outside of an object */ surface tex_blend(float Kd = 1, /* basic brightness */ blend = 1; /* allows for blending texture in parameters */ string inside_map = "", /* inside texture map */ outside_map = "" /* outside texture map */) { color surfcolor, t1, t2; /* defines surface, t1, and t2 */ /* since textures can not be used in a MIX, the textures need to be redefined into varibles that can */ /* can be used within MIX */ t1 = texture(inside_map); t2 = texture(outside_map); /* make a copy of the surface normal one unit in length */ normal n = normalize(N); normal nf = faceforward(n, I); /* set the apparent surface opacity */ Oi = Os; /* defines the default for surface color */ surfcolor = mix(t1, t2, blend); /* this If statement define how the shader needs to blends between the textures */ if(n == nf){ surfcolor = mix(t2, t1, blend); } /* calculate the diffuse lighting component */ color diffusecolor = Kd * diffuse(nf); /* calculate the apparent surface color */ Ci = Oi * Cs * surfcolor * diffusecolor; }