[FEAT] Material add transparency and refractive_index into material

This commit is contained in:
NADAL Jean-Baptiste
2024-03-06 16:59:43 +01:00
parent cd67bdbda5
commit 548d765fcb
18 changed files with 157 additions and 28 deletions

View File

@@ -280,3 +280,43 @@ SCENARIO("The reflected color at the maximum recursive depth", "[features/world.
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("Transparency and Refractive Index for the default material", "[features/materials.feature]")
{
GIVEN("m <- material()")
{
Material m;
THEN("m.transparency = 0.0")
{
REQUIRE(m.transparency() == 0.0);
}
AND_THEN("m.refractive_index = 1.0")
{
REQUIRE(m.refractive_index() == 1.0);
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("A helper for producing a sphere with a glassy material", "[features/spheres.feature]")
{
GIVEN("s <- glass_sphere()")
{
Sphere s = Sphere::Glass();
THEN("s.transform = identity_matrix")
{
REQUIRE(s.transform() == Matrix::identity());
}
AND_THEN("s.material.transparency = 1.0")
{
REQUIRE(s.material().transparency() == 1.0);
}
AND_THEN("s.material.refractive_index = 1.5")
{
REQUIRE(s.material().refractive_index() == 1.5);
}
}
}