Ejemplo n.º 1
0
def build_graph():
    sphere = Sphere(radius=0.3).translate((0.2, 0, 0))
    # box = Box((0.1, 0.2, 0.3)).translate((0, -0.1, 0.1))
    # box = SmoothBox((0.1, 0.2, 0.3)).translate((0, -0.1, 0.1))
    # sdf = sphere.union(box)
    sdf = sphere
    # sdf = box
    # translation = -tf.ones(shape=(3,), dtype=tf.float32)
    # sdf = sdf.translate(translation)
    scale_factor = tf.constant(0.8, dtype=tf.float32)
    sdf = sdf.scale(scale_factor)

    eye = tf.constant([[1, 1, 1]], dtype=tf.float32)
    center = tf.zeros(shape=(1, 3), dtype=tf.float32)
    world_up = tf.constant([[0, 0, 1]], dtype=tf.float32)

    fov_y = tf.ones(shape=(1, ), dtype=tf.float32) * 40.0
    focal_length_px = camera_utils.get_focal_length(image_height, fov_y, 'deg')

    camera_matrices = camera_utils.look_at(eye, center, world_up)

    R, t = homogeneous.split_homogeneous(camera_matrices)

    directions = camera_utils.get_transformed_camera_rays(
        image_height, image_width, focal_length_px, R)

    return sdf, eye, directions, scale_factor
Ejemplo n.º 2
0
sphere = Sphere(radius=0.3).translate((0.2, 0, 0))
box = Box((0.1, 0.2, 0.3)).translate((0, -0.1, 0.1))
sdf = sphere.union(box)
scale_factor = tf.constant(0.8, dtype=tf.float32)
sdf = sdf.scale(scale_factor)

eye = tf.constant([[1, 1, 1]], dtype=tf.float32)
center = tf.zeros(shape=(1, 3), dtype=tf.float32)
world_up = tf.constant([[0, 0, 1]], dtype=tf.float32)

fov_y = tf.ones(shape=(1,), dtype=tf.float32) * 40.0

image_height = 64
image_width = 64

camera_matrices = camera_utils.look_at(eye, center, world_up)

R, t = homogeneous.split_homogeneous(camera_matrices)

directions = camera_utils.get_transformed_camera_rays(
    image_height, image_width, fov_y, R)


max_length = 3
args = sdf, eye, directions, max_length
kwargs = dict(threshold=threshold)
lengths, points, hit, missed = render.get_intersections(
    *args, back_prop=True, linearize=False, **kwargs)
fixed_lengths, fp, f_hit, f_missed = render.get_intersections(
    *args, back_prop=True, linearize=True, **kwargs)