[FEAT] refraction tips7 is now working
This commit is contained in:
@@ -189,9 +189,10 @@ IntersectionData Intersection::prepare_computations(const Ray &a_ray, Intersecti
|
|||||||
the_data.set_point(a_ray.position(m_distance_t));
|
the_data.set_point(a_ray.position(m_distance_t));
|
||||||
the_data.set_eyev(-a_ray.direction());
|
the_data.set_eyev(-a_ray.direction());
|
||||||
the_data.set_normalv(m_shape->normal_at(the_data.point()));
|
the_data.set_normalv(m_shape->normal_at(the_data.point()));
|
||||||
|
the_data.set_inside();
|
||||||
the_data.set_over_point(the_data.point() + the_data.normalv() * kEpsilon);
|
the_data.set_over_point(the_data.point() + the_data.normalv() * kEpsilon);
|
||||||
the_data.set_under_point(the_data.point() - the_data.normalv() * kEpsilon);
|
the_data.set_under_point(the_data.point() - the_data.normalv() * kEpsilon);
|
||||||
the_data.set_inside();
|
|
||||||
the_data.set_reflectv(a_ray.direction().reflect(the_data.normalv()));
|
the_data.set_reflectv(a_ray.direction().reflect(the_data.normalv()));
|
||||||
|
|
||||||
if (a_collection == nullptr)
|
if (a_collection == nullptr)
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ Color World::refracted_color(const IntersectionData &an_intersection_data, uint3
|
|||||||
|
|
||||||
// Find the color of the refracted ray, making sure to multiply by the transparency value
|
// Find the color of the refracted ray, making sure to multiply by the transparency value
|
||||||
// to account for any opacity
|
// to account for any opacity
|
||||||
the_color = color_at(the_refracted_ray, a_remaining - 1) * an_intersection_data.object()->material().transparency();
|
the_color = color_at(the_refracted_ray, a_remaining - 1) * the_transparency;
|
||||||
|
|
||||||
return the_color;
|
return the_color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,20 @@ Intersections Sphere::local_intersect(const Ray &a_ray)
|
|||||||
if (discriminant >= 0)
|
if (discriminant >= 0)
|
||||||
{
|
{
|
||||||
double the_sqrt = std::sqrt(discriminant);
|
double the_sqrt = std::sqrt(discriminant);
|
||||||
the_intersections.add(Intersection((-the_b - the_sqrt) / (2 * the_a), this));
|
double t1, t2;
|
||||||
the_intersections.add(Intersection((-the_b + the_sqrt) / (2 * the_a), this));
|
t1 = (-the_b - the_sqrt) / (2 * the_a);
|
||||||
|
t2 = (-the_b + the_sqrt) / (2 * the_a);
|
||||||
|
|
||||||
|
if (t1 < t2)
|
||||||
|
{
|
||||||
|
the_intersections.add(Intersection(t1, this));
|
||||||
|
the_intersections.add(Intersection(t2, this));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
the_intersections.add(Intersection(t2, this));
|
||||||
|
the_intersections.add(Intersection(t1, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return the_intersections;
|
return the_intersections;
|
||||||
|
|||||||
@@ -296,16 +296,10 @@ SCENARIO("Shading an intersection from the inside", "[features/world.feature]")
|
|||||||
AND_WHEN("c <- shade_hit(w, comps)")
|
AND_WHEN("c <- shade_hit(w, comps)")
|
||||||
{
|
{
|
||||||
Color c = w.shade_hit(comps);
|
Color c = w.shade_hit(comps);
|
||||||
#if 0 // Not working anymore with shadow.
|
|
||||||
THEN("c = color(0.90498, 0.90498, 0.90498)")
|
THEN("c = color(0.90498, 0.90498, 0.90498)")
|
||||||
{
|
{
|
||||||
REQUIRE(c == Color(0.90498, 0.90498, 0.90498));
|
REQUIRE(c == Color(0.90498, 0.90498, 0.90498));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
THEN("c = color(0.1, 0.1, 0.1)")
|
|
||||||
{
|
|
||||||
REQUIRE(c == Color(0.1, 0.1, 0.1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user