| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- surface 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;
- // 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 );
- }
- 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) );
- Ci = (Cs * (Ka * env + Kd * lambert) + 1 * Ks * spec);
- }
|