RGBColor Transparent::shade(ShadeRec& sr) { if (ior_tex != NULL) { //get current ior float i = 0; i = ior_tex->get_color(sr).average()*1.2; set_ior(i); } RGBColor L(SV_Phong::shade(sr)); // direct illumination Vector3D wo = -sr.ray.d; Vector3D wi; RGBColor fr = reflective_brdf->sample_f(sr, wo, wi); Ray reflected_ray(sr.hit_point, wi); if (specular_btdf->tir(sr)) L += sr.w.tracer_ptr->trace_ray(reflected_ray, sr.depth + 1); else { Vector3D wt; RGBColor ft = specular_btdf->sample_f(sr,wo,wt); Ray transmitted_ray(sr.hit_point, wt); L += fr * sr.w.tracer_ptr->trace_ray(reflected_ray, sr.depth + 1) * fabs(sr.normal * wi); L += ft * sr.w.tracer_ptr->trace_ray(transmitted_ray, sr.depth + 1) * fabs(sr.normal * wt); } return (L); }
static void test_set(void) { char *keys1[] = {"a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a"}; char *keys2[] = {"a", "l", "a", "c", "a", "z", "a", "m"}; SetObject *a = set_new(); SetObject *b = set_new(); set_addfrom(a, (void**)keys1, 11); set_addfrom(b, (void**)keys2, 8); set_print(a); // { 'c', 'd', 'r', 'a', 'b', } set_print(b); // { 'c', 'l', 'm', 'a', 'z', } set_print(set_rsub(a, b)); //{ 'd', 'b', 'r', } set_print(set_ror(a, b)); //{ 'a', 'b', 'c', 'd', 'l', 'm', 'r', 'z', } set_print(set_rand(a, b)); //{ 'c', 'a', } set_print(set_rxor(a, b)); //{ 'b', 'd', 'l', 'm', 'r', 'z', } set_ior(a, b); set_print(a); set_isub(a, b); set_print(a); set_ixor(a, b); set_print(a); set_iand(a, b); set_print(a); set_free(a); set_free(b); char *keys3[] = {"a", "b"}; char *keys4[] = {"a", "b", "d", "c", "e", "f", "g", "h"}; SetObject *c = set_new(); SetObject *d = set_new(); set_addfrom(c, (void**)keys3, 2); set_addfrom(d, (void**)keys4, 8); set_print(set_xor(c, d)); set_print(set_and(c, d)); set_print(set_sub(c, d)); }