Refraction seems to work. Still need to do a nice scene.

This commit is contained in:
Godzil
2020-02-21 22:50:12 +00:00
parent df52cb36db
commit 3db0aaaeac
9 changed files with 274 additions and 16 deletions

View File

@@ -27,18 +27,18 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
}
Tuple overHitP = hitP + normalV * getEpsilon();
Tuple underHitP = hitP - normalV * getEpsilon();
Tuple reflectV = r.direction.reflect(normalV);
if (xs != nullptr)
{
List containers;
int j, k;
Intersection hit = xs->hit();
for(j = 0; j < xs->count(); j++)
{
Intersection i = (*xs)[j];
if (hit == i)
if (*this == i)
{
if (!containers.isEmpty())
{
@@ -55,12 +55,11 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
containers.append(i.object);
}
if (hit == i)
if (*this == i)
{
if (!containers.isEmpty())
{
Shape *cur = containers.last();
n2 = cur->material.refractiveIndex;
n2 = containers.last()->material.refractiveIndex;
}
/* End the loop */
@@ -78,5 +77,6 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
inside,
reflectV,
n1,
n2);
n2,
underHitP);
}