src/raytracer.cc
branchpyrit
changeset 56 d4481fc43952
parent 55 f6d75ae82c88
child 67 249553e1d4fe
equal deleted inserted replaced
55:f6d75ae82c88 56:d4481fc43952
   204 					const Float Rpar = (n2*cos_i - n1*cos_t)*Rdiv;
   204 					const Float Rpar = (n2*cos_i - n1*cos_t)*Rdiv;
   205 					const Float R = (Rper*Rper + Rpar*Rpar)/2;
   205 					const Float R = (Rper*Rper + Rpar*Rpar)/2;
   206 					refl += R*trans;
   206 					refl += R*trans;
   207 					trans = (1-R)*trans;
   207 					trans = (1-R)*trans;
   208 					Vector3 newdir = n * ray.dir + (n*cos_i - cos_t) * normal;
   208 					Vector3 newdir = n * ray.dir + (n*cos_i - cos_t) * normal;
   209 					Ray newray = Ray(P, newdir);
   209 					Ray newray = Ray(P + 0.001*newdir, newdir);
   210 					trans_col = raytrace(newray, depth + 1, nearest_shape);
   210 					trans_col = raytrace(newray, depth + 1, NULL);
   211 				}
   211 				}
   212 			}
   212 			}
   213 			col = (1-refl-trans)*col + refl*refl_col + trans*trans_col;
   213 			col = (1-refl-trans)*col + refl*refl_col + trans*trans_col;
   214 		}
   214 		}
   215 
   215