Exemple #1
0
 def get_direction(self, shading_point):
     self.w = shading_point.normal
     up     = Vector(0.003, 1.0, 0.007)
     self.v = up.cross(self.w)
     self.v = self.v.normalize()
     self.u = self.v.cross(self.w)
     sp = self.sampler.sample_hemisphere()
     self.wi = self.u.scalar(sp.x) + self.v.scalar(sp.y) + self.w.scalar(sp.z)
     return self.wi.scalar(-1.0)
Exemple #2
0
    def sample_f(self, shading_point):
        w = shading_point.normal
        # jitter the up vector
        v = Vector(0.0024, 1.0, 0.0081).cross(w)
        v = v.normalize()
        u = v.cross(w)

        sample_point = self.sampler.sample_hemisphere()
        wi = sample_point.x * u + sample_point.y * v + sample_point.z * w
        wi = wi.normalize()
        pdf = shading_point.normal * wi / math.pi
        color = self.surface.get_color(shading_point)
        return pdf, wi, (self.kd * color / math.pi)