/**************************** Displacement Shader (c) Mad Processor, 2009 As with all baking-compatible shaders, one should not use the faceforward() call. In-House disp workflow is 0.5-based, meaning that a magnitude of 0.5 does nothing, 0 goes inward, 1 goes outward. *****************************/ displacement lm_disp( float Km = 1.5; string texname = ""; float offset = -0.5; ) { float surface_mag, layer_mag; point Ndiff; if(texname != "") //surface_mag = float texture( texname, "fill", 0.5, s, t ); surface_mag = float texture( texname, "fill", 0.5 ); else surface_mag = 0.5; Ndiff = normalize(N) - normalize(Ng); //P += (-0.5)*Km*normalize(N); P += (surface_mag+offset)*Km*normalize(N); //P += (surface_mag-0.5*offset)*Km*normalize(N); //P += ((Km * surface_mag+offset) * normalize(N)); N = normalize(calculatenormal(P)) + Ndiff; }