Skip to content

Commit

Permalink
Merge branch 'refraction' of https://github.com/slmtnm/pyRT into refr…
Browse files Browse the repository at this point in the history
…action
  • Loading branch information
PinkOink committed Mar 31, 2021
2 parents 2e1957d + 602e8d6 commit 53f2f3e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pyrt/renderer/simplert.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ def __init__(self, shadow=False, iterations=1):
if self.iterations>1:
print("# Iterations: " + str(self.iterations))

self._epsilon = 1e-4 # for float comparison
self._refract_offset = 1e-6 # refraction ray origin offset

def _shade(self, scene: Scene, ray: Ray, hitrecord: HitRecord) -> tuple:
r = g = b = 0 # background color
hit = False
Expand Down Expand Up @@ -80,7 +77,7 @@ def _recurse_shade(self, scene: Scene, ray: Ray, iteration_num: int) -> tuple:
if not hit or iteration_num == 0:
return r, g, b

if hitrecord.material.reflectivity > self._epsilon:
if hitrecord.material.reflectivity > G_EPSILON:
reflect_ray = Ray(hitrecord.point, reflect3(hitrecord.normal_g, ray.direction))
new_r, new_g, new_b = self._recurse_shade(scene, reflect_ray, iteration_num - 1)

Expand All @@ -92,9 +89,9 @@ def _recurse_shade(self, scene: Scene, ray: Ray, iteration_num: int) -> tuple:

self.num_secondary_rays += 1

if hitrecord.material.transparency > self._epsilon:
if hitrecord.material.transparency > G_EPSILON:
refract_ray = Ray(
hitrecord.point + normalize3(ray.direction) * self._refract_offset,
hitrecord.point + normalize3(ray.direction) * G_EPSILON,
refract3(normalize3(hitrecord.normal_g), normalize3(ray.direction), hitrecord.material.refraction)
)
new_r, new_g, new_b = self._recurse_shade(scene, refract_ray, iteration_num - 1)
Expand Down

0 comments on commit 53f2f3e

Please sign in to comment.