lm_disp.sl 899 B

1234567891011121314151617181920212223242526272829303132333435
  1. /****************************
  2. Displacement Shader
  3. (c) Mad Processor, 2009
  4. As with all baking-compatible
  5. shaders, one should not use
  6. the faceforward() call.
  7. In-House disp workflow is 0.5-based, meaning
  8. that a magnitude of 0.5 does nothing, 0 goes inward,
  9. 1 goes outward.
  10. *****************************/
  11. displacement lm_disp(
  12. float Km = 1.5;
  13. string texname = "";
  14. float offset = -0.5;
  15. )
  16. {
  17. float surface_mag, layer_mag;
  18. point Ndiff;
  19. if(texname != "")
  20. //surface_mag = float texture( texname, "fill", 0.5, s, t );
  21. surface_mag = float texture( texname, "fill", 0.5 );
  22. else surface_mag = 0.5;
  23. Ndiff = normalize(N) - normalize(Ng);
  24. //P += (-0.5)*Km*normalize(N);
  25. P += (surface_mag+offset)*Km*normalize(N);
  26. //P += (surface_mag-0.5*offset)*Km*normalize(N);
  27. //P += ((Km * surface_mag+offset) * normalize(N));
  28. N = normalize(calculatenormal(P)) + Ndiff;
  29. }