Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing point light sources for glossy surfaces #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sightpy/geometry/triangle_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

10 changes: 6 additions & 4 deletions sightpy/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, pos, color):
self.color = color

@abstractmethod
def get_L(self):
def get_L(self, M):
pass

@abstractmethod
Expand All @@ -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))
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion sightpy/materials/glossy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down