Beispiel #1
0
    def __init__(self, o2w: Transform, w2o: Transform, radius: float, zmin: float, zmax: float, phimax: float):
        super().__init__(o2w, w2o)

        self.radius = radius
        self.zmin = get_clamp(min(zmin, zmax), -radius, radius)
        self.zmax = get_clamp(max(zmin, zmax), -radius, radius)
        self.thetaMin = math.acos(get_clamp(zmin/radius, -1.0, 1.0))
        self.thetaMax = math.acos(get_clamp(zmax/radius, -1.0, 1.0))
        self.phimax = math.radians(get_clamp(phimax, 0.0, 360.0))
        self.radius_squared = self.radius * self.radius
Beispiel #2
0
 def draw(self, args):
     pixels = args[0]
     bucket_extend = args[1]
     i = 0
     for y in range(bucket_extend.start_y, bucket_extend.end_y, 1):
         for x in range(bucket_extend.start_x, bucket_extend.end_x, 1):
             r, g, b = pixels[i].toRGB()
             r = get_clamp(255.0 * pow(r, 1.0 / 2.2), 0.0, 255.0)
             g = get_clamp(255.0 * pow(g, 1.0 / 2.2), 0.0, 255.0)
             b = get_clamp(255.0 * pow(b, 1.0 / 2.2), 0.0, 255.0)
             self.camera.film.data[y, x] = int(b) | int(g) << 8 | int(r) << 16
             i += 1
Beispiel #3
0
    def Evaluate(self, cosi: float)->Spectrum:
        cosi = get_clamp(cosi, -1.0, 1.0)

        # Compute indices of refraction for dielectric
        entering = cosi > 0.0
        ei = self.eta_i
        et = self.eta_t
        if entering:
            ei, et = et, ei

        # Compute _sint_ using Snell's law
        sint = ei/et * math.sqrt(max(0.0, 1.0 - cosi*cosi))
        if sint >= 1.0:
            # Handle total internal reflection
            return 1.0

        cost = math.sqrt(max(0.0, 1.0 - sint*sint))
        return FrDiel(math.fabs(cosi), cost, ei, et)
Beispiel #4
0
    def get_bsdf(self, dgGeom: DifferentialGeometry, dgShading: DifferentialGeometry)->[BSDF]:

        dgs = DifferentialGeometry()
        if self.bumpMap is None:
            dgs = dgShading
        else:
            #todo Bump(bumpMap, dgGeom, dgShading, &dgs);
            pass

        bsdf = BSDF(dgs, dgGeom.normal)

        r = self.Kd.get_evaluate(dgs).get_clamp()
        sig = get_clamp(self.sigma.get_evaluate(dgs), 0.0, 90.0)

        if r.get_is_black():
            bsdf.add(OrenNayar(r,sig))
        else:
            bsdf.add(Lambertian(r))

        return bsdf
Beispiel #5
0
def  SinPhi(w: Vector3d)->float:
    sintheta = SinTheta(w)
    if sintheta == 0.0:
        return 0.0
    return get_clamp(w.y / sintheta, -1.0, 1.0)
Beispiel #6
0
 def get_pos_to_voxel(self, point: Point3d, axis: int) -> int:
     v = int((point[axis] - self.bounds.point_min[axis]) * self.inv_width[axis])
     return get_clamp(v, 0, self.nVoxels[axis] - 1)