| cloud | R Documentation |
Create a cloud volume with billowing Perlin-noise density. Add it to a scene
with add_object(); rendering automatically selects integrator_type = "nee". Requires the
suggested package ambient to generate the density field.
cloud(
x = 0,
y = 0,
z = 0,
width = 100,
height = 25,
depth = 75,
style = c("cumulus", "stratus"),
seed = 42,
resolution = 128,
coverage = 0.5,
detail = 0.35,
optical_depth = 8,
g = 0.65,
angle = c(0, 0, 0),
order_rotation = c(1, 2, 3),
scale = c(1, 1, 1),
t = 0,
animation_seed = 1,
haze = FALSE,
haze_density_threshold = 0.05
)
x |
Default |
y |
Default |
z |
Default |
width |
Default |
height |
Default |
depth |
Default |
style |
Default |
seed |
Default |
resolution |
Default |
coverage |
Default |
detail |
Default |
optical_depth |
Default |
g |
Default |
angle |
Default |
order_rotation |
Default |
scale |
Default |
t |
Default |
animation_seed |
Default |
haze |
Default |
haze_density_threshold |
Default |
The local bounding box is centered at zero before object transforms,
spanning -c(width, height, depth) / 2 to c(width, height, depth) / 2.
The density fades to vacuum at all six faces; the box has no visible surface.
An unrotated, unscaled cloud with base altitude b has y = b + height / 2.
The center describes the box, not the irregular density's center of mass.
Positions and dimensions use scene units. Setting the dimensions rebuilds
the field and normalizes extinction by height. Applying scale stretches
the existing volume without renormalizing extinction, so stretching it along
a ray increases that ray's optical depth. Standard group_objects(),
animate_objects(), and create_instances() operations transform the cloud
using the same object machinery as other closed shapes.
Evolution adds small, bounded perturbations to the broad and fine noise
fields using separately seeded four-dimensional simplex noise (space and
time). Subtracting the perturbation at time zero anchors the original shape.
Broad domes, the base profile, and edge fades stay fixed while local density
swells and erodes. Evolution is procedural rather than a fluid simulation;
cloud mass is not conserved. Use x, y, and z for bulk movement.
Rebuild the cloud with a new t value for each rendered frame.
animate_objects() animates its transform; it does not evolve the density
within a frame or during the shutter interval.
Cloud scattering is separate from sky_light()'s clear-air atmospheric haze.
Avoid intersecting, non-nested cloud boxes, including their empty edge cells:
these are separate medium boundaries. Use one larger field for a connected
bank. The attached grid_medium() is stored in
object$shape_info[[1]]$medium for further density or scattering adjustments.
A single-row ray_scene containing an invisible box with an attached
cloud density grid.
sky_light(), grid_medium(), set_medium()
# The default cloud is centered at the origin. Raise a cloud by its center
# to put its base above the ground, then rotate the entire density field.
puff = cloud(y = 20, width = 60, height = 20, depth = 40,
angle = c(0, 25, 0), resolution = 64, optical_depth = 4)
scene = generate_ground(material = diffuse("#699447")) |>
add_object(puff) |>
add_object(sphere(x = -50, y = 80, z = -30, radius = 15,
material = light(intensity = 40)))
render_scene(scene, lookfrom = c(80, 35, -100), lookat = c(0, 20, 0),
fov = 35, integrator_type = "nee", samples = 64,
clamp_value = Inf, aperture = 0)
# Reuse the shape at another position, or change the style and its detail.
bank = cloud(x = 0, y = w0, z = 6, style = "stratus", seed = 17,
width = 80, height = 10, depth = 50,
coverage = 0.7, detail = 0.2, optical_depth = 6, g = 0.6)
scaled = cloud(scale = c(1.5, 1, 0.75), angle = c(10, 30, 0),
order_rotation = c(2, 1, 3), resolution = 64)
generate_ground(material = diffuse("#699447")) |>
add_object(bank) |>
add_object(sphere(x = -50, y = 80, z = -30, radius = 15,
material = light(intensity = 40))) |>
render_scene(lookfrom = c(80, 100, -100), lookat = c(0, 20, 0),
fov = 35, integrator_type = "nee", samples = 64,
clamp_value = Inf, aperture = 0)
generate_ground(material = diffuse("#699447")) |>
add_object(scaled) |>
add_object(sphere(x = -50, y = 80, z = -30, radius = 15,
material = light(intensity = 40))) |>
render_scene(lookfrom = c(80, 100, -100), lookat = c(0, 20, 0),
fov = 35, integrator_type = "nee", samples = 64,
clamp_value = Inf, aperture = 0)
# Keep seeds and position fixed to evolve the cloud locally over time.
# Rebuilding a frame at the same t value always gives the same cloud.
for (frame in 0:3) {
set.seed(2026)
generate_ground(material = diffuse("#699447")) |>
add_object(cloud(y = 20, width = 60, height = 20, depth = 40,
seed = 42, t = frame / 3, animation_seed = 17,
resolution = 64, optical_depth = 4)) |>
add_object(sphere(x = -50, y = 80, z = -30, radius = 15,
material = light(intensity = 40))) |>
render_scene(lookfrom = c(80, 35, -100), lookat = c(0, 20, 0),
width = 256, height = 160, fov = 35, integrator_type = "nee",
samples = 64, iso = 100, aperture = 0)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.