bake.sl 833 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. surface bake (float Ka = 0.2, Kd = 0.5, Ks = 0.5;
  2. string bakefile = "";
  3. float roughness = 0.1;
  4. )
  5. {
  6. normal Nn = normalize(N);
  7. vector V = normalize(-I);
  8. extern point P;
  9. color env = 0;
  10. color lambert = 0;
  11. // ENV ILLUMINANCE LOOP
  12. illuminance( "env", P,Nn, PI/2 )
  13. {
  14. env += Cs * Cl * normalize(L).Nn;
  15. bake( concat(bakefile,"_env.bake&binary"), s, t, env );
  16. }
  17. // SUN ILLUMINANCE LOOP
  18. illuminance("sun", P, Nn, PI/2 )
  19. {
  20. lambert += Cl * normalize(L).Nn;
  21. bake( concat(bakefile,"_diff.bake&binary"), s, t, lambert );
  22. }
  23. color spec = specular(Nn, V, roughness);
  24. bake( concat(bakefile,"_spec.bake&binary"), s, t, spec );
  25. bake( concat(bakefile,"_shading.bake&binary"), s, t, (Ka * env + Kd * lambert) );
  26. Ci = (Cs * (Ka * env + Kd * lambert) + 1 * Ks * spec);
  27. }