diff --git a/pyrt/geometry/sphere.py b/pyrt/geometry/sphere.py index 707204a..10f4c40 100644 --- a/pyrt/geometry/sphere.py +++ b/pyrt/geometry/sphere.py @@ -73,6 +73,7 @@ def hit(self, ray: Ray, hitrecord: HitRecord) -> bool: hitrecord.normal = hitrecord.normal_g hitrecord.color = Vec3(1., 1., 1.) # spheres don't have interpolated colors, set to white hitrecord.material = self.material + hitrecord.texcoord = self.calcTexcoord(hitrecord.point) return True return False diff --git a/pyrt/geometry/triangle.py b/pyrt/geometry/triangle.py index 1f412f7..8033367 100644 --- a/pyrt/geometry/triangle.py +++ b/pyrt/geometry/triangle.py @@ -202,8 +202,10 @@ def hit(self, ray: Ray, hitrecord: HitRecord) -> bool: cV = self.c.color - self.a.color hitrecord.color = self.a.color + cU * u + cV * v hitrecord.material = self.material + hitrecord.texcoord = self.calcTexcoord(hitrecord.point) - hitrecord.point = ray.start + t * ray.direction + # why would we? + # hitrecord.point = ray.start + t * ray.direction return True diff --git a/pyrt/geometry/vertex.py b/pyrt/geometry/vertex.py index e5ea0fd..b401395 100644 --- a/pyrt/geometry/vertex.py +++ b/pyrt/geometry/vertex.py @@ -59,11 +59,13 @@ def __init__(self, **kwargs): else: raise ValueError("color must be specified as Vec3 or list/tuple with 3 components") - ''' if "texcoord" in kwargs: if type(kwargs["texcoord"]) == Vec2: - pass + self.texcoord = kwargs["texcoord"].copy() elif type(kwargs["texcoord"]) == tuple or type(kwargs["texcoord"]) == list: + if len(kwargs["texcoord"]) == 2: + self.texcoord = Vec2(kwargs["texcoord"][0], kwargs["texcoord"][1]) + else: + raise ValueError("Wrong number of components for texcoord") else: raise ValueError("position must be specified as Vec2 or list/tuple") - '''