mp_light_spot.sl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /****************************
  2. Shadowed Spot Light Shader
  3. (c) Mad Processor, 2009
  4. As with all baking-compatible
  5. shaders, one should not use
  6. the faceforward() call.
  7. *****************************/
  8. light
  9. mp_light_spot(
  10. float intensity = 1;
  11. color lightcolor = 1;
  12. uniform string shadowmap = "";
  13. uniform float blur = 0;
  14. point from = point "shader" (0,0,0);
  15. point to = point "shader" (0,0,1);
  16. float coneangle = radians(30);
  17. float conedeltaangle = radians(5);
  18. float beamdistribution = 2;
  19. float decay = 2.0;
  20. float __nondiffuse = 0, __nonspecular = 0;
  21. float samples = 32;
  22. string __category = "sun";)
  23. {
  24. uniform vector A = (to - from) / length(to - from);
  25. illuminate( from, A, coneangle )
  26. {
  27. //standard shadow
  28. color shad = shadow( "raytrace", Ps, "blur", blur, "samples", samples );
  29. //float distance_squared = L.L;
  30. //float distance = sqrt( distance_squared );
  31. //float cosangle = L.A / distance;
  32. //color shad = transmission( Ps, from, "samples", samples, "samplecone", blur, "bias", .08 );
  33. //Cl = atten * (1-shad) * intensity * lightcolor;
  34. //Cl = (1-shad) * intensity * lightcolor;
  35. //Cl = intensity * lightcolor;
  36. //Cl = 0;
  37. Cl = intensity * (1-shad);
  38. }
  39. }