From c493904cafaf6dba88547964dd4f9d8b9ca2f175 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 4 Oct 2022 01:19:30 +0000 Subject: [PATCH 1/2] fixing point light sources for glossy surfaces --- sightpy/lights.py | 10 ++++++---- sightpy/materials/glossy.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sightpy/lights.py b/sightpy/lights.py index 9044ad3..4f8b48c 100644 --- a/sightpy/lights.py +++ b/sightpy/lights.py @@ -10,7 +10,7 @@ def __init__(self, pos, color): self.color = color @abstractmethod - def get_L(self): + def get_L(self, M): pass @abstractmethod @@ -26,8 +26,10 @@ class PointLight(Light): def __init__(self, pos, color): self.pos = pos self.color = color - def get_L(self): - return (self.pos - M)*(1./(dist_light)) + def get_L(self, M): + Ldir = self.pos - M + Ldir = Ldir / np.linalg.norm(Ldir) + return Ldir def get_distance(self, M): return np.sqrt((self.pos - M).dot(self.pos - M)) @@ -39,7 +41,7 @@ class DirectionalLight(Light): def __init__(self, Ldir, color): self.Ldir = Ldir self.color = color - def get_L(self): + def get_L(self, M): return self.Ldir def get_distance(self, M): diff --git a/sightpy/materials/glossy.py b/sightpy/materials/glossy.py index 8a98043..46efe41 100644 --- a/sightpy/materials/glossy.py +++ b/sightpy/materials/glossy.py @@ -36,7 +36,7 @@ def get_color(self, scene, ray, hit): for light in scene.Light_list: - L = light.get_L() # direction to light + L = light.get_L(hit.point) # direction to light dist_light = light.get_distance(hit.point) # distance to light NdotL = np.maximum(N.dot(L), 0.) lv = light.get_irradiance(dist_light, NdotL) # amount of intensity that falls on the surface From b897341b0f88fc9ed57ec5b438f246b299402f43 Mon Sep 17 00:00:00 2001 From: Chinmay Talegaonkar Date: Tue, 4 Oct 2022 01:23:12 +0000 Subject: [PATCH 2/2] fixing error in triangle mesh --- sightpy/geometry/triangle_mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sightpy/geometry/triangle_mesh.py b/sightpy/geometry/triangle_mesh.py index 7622be2..efec55a 100644 --- a/sightpy/geometry/triangle_mesh.py +++ b/sightpy/geometry/triangle_mesh.py @@ -35,5 +35,5 @@ def __init__(self,file_name, center, material, max_ray_depth,shadow = True): p1 = vs[i[0]] + center p2 = vs[i[1]] + center p3 = vs[i[2]] + center - self.collider_list += [colliders.Triangle_Collider(assigned_primitive = self, p1 =p1, p2 = p2, p3 = p3)] + self.collider_list += [Triangle_Collider(assigned_primitive = self, p1 =p1, p2 = p2, p3 = p3)]