Skip to content

Commit

Permalink
fix rounding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
souhhcong committed Jun 10, 2024
1 parent da11ea4 commit b964141
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions raytracer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ public:
if (objects[sphere_id]->mirror) {
// Reflection
types[ray_depth] = 0;
float epsilon = 1e-6;
float epsilon = 1e-4;
Vector P_adjusted = P + epsilon * N;
Vector new_direction = ray.u - 2 * dot(ray.u, N) * N;
Ray reflected_ray(P_adjusted, new_direction, ray.refraction_index);
ray = reflected_ray;
} else if (objects[sphere_id]->in_refraction_index != objects[sphere_id]->out_refraction_index) {
// Refraction
types[ray_depth] = 0;
float epsilon = 1e-6;
float epsilon = 1e-4;
float refract_ratio;
bool out2in = ray.refraction_index == objects[sphere_id]->out_refraction_index;
if (out2in) {
Expand Down Expand Up @@ -649,7 +649,7 @@ public:
// Get shadow
Vector P_prime;
int sphere_id_shadow;
float epsilon = 1e-6;
float epsilon = 1e-4;
Vector P_adjusted = P + epsilon * N;
Vector N_prime;
bool _ = intersect_all(Ray(P_adjusted, NORMED_VEC(L - P_adjusted)), P_prime, N_prime, sphere_id_shadow);
Expand Down

0 comments on commit b964141

Please sign in to comment.