#include "shading_utils.h" surface lm_bake (float Ka = 0.2, Kd = 0.5, Ks = 0.5; string bakefile = ""; float roughness = 0.1; ) { normal Nn = normalize(N); vector V = normalize(-I); extern point P; color env = 0; color lambert = 0; color occ = 0; color shadowfactor = 0; //float shadow; // ENV ILLUMINANCE LOOP illuminance( "env", P,Nn, PI/2 ) { env += Cs * Cl * normalize(L).Nn; bake( concat(bakefile,"_env.bake&binary"), s, t, env ); } // SUN ILLUMINANCE LOOP illuminance("sun", P, Nn, PI/2 ) { lambert += Cl * normalize(L).Nn; bake( concat(bakefile,"_diff.bake&binary"), s, t, lambert ); } // OCCLUSION ILLUMINANCE LOOP illuminance("occlusion", P, Nn, PI/2 ) { occ += Cl; bake( concat(bakefile,"_occ.bake&binary"), s, t, occ ); } // SHADOW ILLUMINANCE LOOP illuminance("sun", P, Nn, PI/2 ) { shadowfactor += Cl; bake( concat(bakefile,"_shadow.bake&binary"), s, t, shadowfactor ); } color spec = specular(Nn, V, roughness); bake( concat(bakefile,"_spec.bake&binary"), s, t, spec ); bake( concat(bakefile,"_shading.bake&binary"), s, t, (Ka * env + Kd * lambert) ); //float aov_shadow = computeShadowValue(N); //bake( concat(bakefile,"_shadow.bake&binary"), s, t, aov_shadow ); Ci = (Cs * (Ka * env + Kd * lambert) + 1 * Ks * spec); }