Esempio n. 1
0
def path_push(path: Path, ray: Ray):
    # update stuff appropriately
    if path.direction == Direction.STORAGE.value:
        # don't change anything, this is just a stack. this reduces wasted calculation and preserves first-vertex values
        pass
    elif path.ray is None:
        # this shouldn't come up
        pass
    else:
        G = geometry_term(path.ray, ray)
        path.ray.direction = unit(ray.origin - path.ray.origin)
        if path.ray.prev is None:
            # pushing onto stack of 1, just propagate p and color (?)
            ray.color = path.ray.color * G
            ray.p = path.ray.p * G
        else:
            # pushing onto stack of 2 or more, do some work
            brdf = BRDF_function(path.ray.material, -1 * path.ray.prev.direction, path.ray.normal, path.ray.direction,
                                       path.direction)
            ray.color = path.ray.local_color * path.ray.color * brdf * G
            ray.p = path.ray.p * G * BRDF_pdf(path.ray.material, -1 * path.ray.prev.direction, path.ray.normal, path.ray.direction,
                                          path.direction)
        ray.bounces = path.ray.bounces + 1

    # store new ray
    ray.prev = path.ray
    path.ray = ray
Esempio n. 2
0
def path_push(path: Path, ray: Ray):
    # update stuff appropriately
    G = geometry_term(path.ray, ray)
    path.ray.direction = unit(ray.origin - path.ray.origin)
    if path.ray.prev is None:
        # pushing onto stack of 1, just propagate p and color (?)
        ray.color = path.ray.color * G
        ray.p = path.ray.p * G
    else:
        # pushing onto stack of 2 or more, do some work
        brdf = brdf_function(path.ray.material, -1 * path.ray.prev.direction,
                             path.ray.normal, path.ray.direction,
                             path.direction)
        ray.color = path.ray.local_color * path.ray.color * brdf * G
        ray.p = path.ray.p * G * brdf_pdf(
            path.ray.material, -1 * path.ray.prev.direction, path.ray.normal,
            path.ray.direction, path.direction)
    ray.bounces = path.ray.bounces + 1

    # store new ray
    ray.prev = path.ray
    path.ray = ray