public void RefractedColorOfOpaqueSurfaceIsBlack() { var w = World.Default(); var s = w.Objects[0]; var r = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1)); var xs = Intersections.Create(new Intersection(4f, s), new Intersection(6f, s)); var comps = new IntersectionInfo(xs[0], r, xs); PhongShading.RefractedColor(w, comps, 5).Should().Be(Colors.Black); }
public void RefractedColorIsBlackIfRemainingBouncesIsZero() { var w = World.Default(); var s = w.Objects[0]; s.Material.Transparency = 1.0f; s.Material.RefractiveIndex = 1.5f; var r = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1)); var xs = Intersections.Create(new Intersection(4f, s), new Intersection(6f, s)); var comps = new IntersectionInfo(xs[0], r, xs); PhongShading.RefractedColor(w, comps, 0).Should().Be(Colors.Black); }
public void RefractedColorIsBlackForTotalInternalRefraction() { var w = World.Default(); var s = w.Objects[0]; s.Material.Transparency = 1.0f; s.Material.RefractiveIndex = 1.5f; var r = new Ray(new Point(0, 0, MathF.Sqrt(2f) / 2f), new Vector(0, 1, 0)); var xs = Intersections.Create( new Intersection(-MathF.Sqrt(2f) / 2f, s), new Intersection(MathF.Sqrt(2f) / 2f, s)); // Inside sphere so look at second intersection. var comps = new IntersectionInfo(xs[1], r, xs); PhongShading.RefractedColor(w, comps, 5).Should().Be(Colors.Black); }
public void RefractsRayWhenHitsTransparentSurface() { var w = World.Default(); var a = w.Objects[0]; a.Material.Ambient = 1.0f; a.Material.Texture = new TestTexture(); var b = w.Objects[1]; b.Material.Transparency = 1.0f; b.Material.RefractiveIndex = 1.5f; var r = new Ray(new Point(0, 0, 0.1f), new Vector(0, 1, 0)); var xs = Intersections.Create( new Intersection(-0.9899f, a), new Intersection(-0.4899f, b), new Intersection(0.4899f, b), new Intersection(0.9899f, a)); var comps = new IntersectionInfo(xs[2], r, xs); var c = PhongShading.RefractedColor(w, comps, 5); c.Red.Should().BeApproximately(0f, 0.001f); c.Green.Should().BeApproximately(0.99888f, 0.001f); c.Blue.Should().BeApproximately(0.04725f, 0.001f); }