/* basic swap texture shader. Allows the user to define and swap textures between */ /* the inside and outside of an object */ surface tex_swap(float Kd = 1, /* basic brightness */ swap = 0; /* allows for swapping texture in parameters */ string inside_map = "", /* inside texture map */ outside_map = "" /* outside texture map */) { color surfcolor = texture(outside_map); /* defines the default surface texture */ /* 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; /* this IF statement defines which texture the shader needs to apply to what surface */ /* when the swap parameter is set at 0 */ if (swap == 0) { if(n == nf) surfcolor = texture(inside_map); /* if the swap parameter is not 0, then it applies the textures to the opposite surfaces */ }else { surfcolor = texture(inside_map); if(n == nf) surfcolor = texture(outside_map); } /* calculate the diffuse lighting component */ color diffusecolor = Kd * diffuse(nf); /* calculate the apparent surface color */ Ci = Oi * Cs * surfcolor * diffusecolor; }