if (FALSE) { # interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
# Static camera attached to the scene, equivalent to passing lookfrom/lookat
# directly to render_scene().
scene = generate_ground(depth = -0.5, material = diffuse(checkercolor = "blue")) |>
add_object(sphere(y = 0.5, radius = 0.5, material = diffuse(color = "red"))) |>
add_camera(camera(
name = "main",
lookfrom = c(7, 1.5, 10),
lookat = c(0, 0.5, 0),
fov = 15,
filename = NA_character_
))
render_scene(scene, samples = 16, parallel = TRUE)
# Shutter speed is frame-relative: higher values sample a smaller fraction
# of camera/object motion without changing exposure.
fast_shutter_camera = camera(
lookfrom = c(7, 1.5, 10),
lookat = c(0, 0.5, 0),
shutter_speed = 4
)
# Animated camera attached to the scene, equivalent to passing camera_motion
# directly to render_animation().
camera_pos = list(c(0, 1, 15), c(5, -5, 5), c(-5, 5, -5), c(0, 1, -15))
camera_motion = generate_camera_motion(
positions = camera_pos,
lookats = camera_pos,
offset_lookat = 1,
fovs = 80,
frames = 12,
type = "bezier"
)
animated_scene = generate_ground(material = diffuse(checkercolor = "grey20"), depth = -10) |>
add_object(sphere(y = 50, radius = 10, material = light(intensity = 30))) |>
add_object(path(camera_pos, y = -0.2, material = diffuse(color = "red"))) |>
add_camera(camera(
name = "flythrough_blur",
motion = camera_motion,
camera_motion_blur = TRUE,
shutter_speed = 2
)) |>
add_camera(camera(
name = "flythrough_no_blur",
motion = camera_motion,
camera_motion_blur = FALSE
)) |>
add_camera(camera(
name = "flythrough_medium_blur",
motion = camera_motion,
camera_motion_blur = FALSE,
shutter_speed = 4
))
#We can render these individual cameras by calling out their specific name in render_scene()
#With no blur
render_scene(
animated_scene,
camera = "flythrough_no_blur",
mode = "animation",
samples = 16,
start_frame = 1,
end_frame = 2,
sample_method = "sobol_blue",
clamp_value = 10,
width = 400,
height = 400
)
#Now, with blur
render_scene(
animated_scene,
camera = "flythrough_blur",
mode = "animation",
samples = 16,
start_frame = 1,
end_frame = 2,
sample_method = "sobol_blue",
clamp_value = 10,
width = 400,
height = 400
)
#Now, with less blur
#' #Now, with blur
render_scene(
animated_scene,
camera = "flythrough_medium_blur",
mode = "animation",
samples = 16,
start_frame = 1,
end_frame = 2,
sample_method = "sobol_blue",
clamp_value = 10,
width = 400,
height = 400
)
}
Run the code above in your browser using DataLab