Skip to content

Instantly share code, notes, and snippets.

@marcosci
Created November 12, 2021 08:44
Show Gist options
  • Save marcosci/f21c030d082a9edc2afe5bd31fb17d47 to your computer and use it in GitHub Desktop.
Save marcosci/f21c030d082a9edc2afe5bd31fb17d47 to your computer and use it in GitHub Desktop.
library(rayrender)
# animate with textures from
# https://www.solarsystemscope.com/textures/
for (i in seq(360, 1, by = -1)) {
generate_studio(depth = -1.3, material = diffuse(color = "white")) %>%
add_object(sphere(
x = -3.2- 0.1,
y = 0,
z = 0,
radius = 0.04,
#material = diffuse(color = "#C9C8C7",),
material = diffuse(image_texture = "textures/2k_mercury.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -3- 0.1,
y = 0,
z = 0,
radius = 0.09,
# material = diffuse(color = "#F2D79E",),
material = diffuse(image_texture = "textures/2k_venus_atmosphere.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -2.75- 0.1,
y = 0,
z = 0,
radius = 0.1,
#material = diffuse(color = "#46CEB3",),
material = diffuse(image_texture = "textures/2k_earth_daymap.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -2.55- 0.1,
y = 0,
z = 0,
radius = 0.05,
#material = diffuse(color = "#C55835",),
material = diffuse(image_texture = "textures/2k_mars.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -1.3- 0.1,
y = 0,
z = 0,
radius = 1.12,
#material = diffuse(color = "#DAC495",),
material = diffuse(image_texture = "textures/2k_jupiter.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 0.8- 0.1,
y = 0,
z = 0,
radius = 0.94,
#material = diffuse(color = "#E9C756",),
material = diffuse(image_texture = "textures/2k_saturn.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 2.2 - 0.1,
y = 0,
z = 0,
radius = 0.4,
#material = diffuse(color = "#98C3C3",),
material = diffuse(image_texture = "textures/2k_uranus.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 3.05 - 0.1,
y = 0,
z = 0,
radius = 0.39,
#material = diffuse(color = "#517FDA",),
material = diffuse(image_texture = "textures/2k_neptune.jpeg"),
angle = c(0, -i / 2, 0)
)) %>%
render_scene(
samples = 500,
aperture = 0,
lookfrom = c(0, 1, 20),
parallel = TRUE,
width = 800,
height = 800,
sample_method = "sobol",
filename = sprintf("renderings/universe%d.png", i)
)
}
system("ffmpeg -framerate 30 -i renderings/universe%d.png -pix_fmt yuv420p renderings/universe.mp4")
# generate more artsy version with sun included (material = light)
# remove that part to have a "univers" without a sun
generate_studio(depth = -1.3, material = diffuse(color = "white")) %>%
add_object(sphere(
x = -3.2- 0.1,
y = 0,
z = 0,
radius = 0.04,
material = diffuse(color = "#C9C8C7",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -3- 0.1,
y = 0,
z = 0,
radius = 0.09,
material = diffuse(color = "#F2D79E",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -2.75- 0.1,
y = 0,
z = 0,
radius = 0.1,
material = diffuse(color = "#46CEB3",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -2.55- 0.1,
y = 0,
z = 0,
radius = 0.05,
material = diffuse(color = "#C55835",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -1.3- 0.1,
y = 0,
z = 0,
radius = 1.12,
material = diffuse(color = "#DAC495",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 0.8- 0.1,
y = 0,
z = 0,
radius = 0.94,
material = diffuse(color = "#E9C756",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 2.2 - 0.1,
y = 0,
z = 0,
radius = 0.4,
material = diffuse(color = "#98C3C3",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = 3.05 - 0.1,
y = 0,
z = 0,
radius = 0.39,
material = diffuse(color = "#517FDA",),
angle = c(0, -i / 2, 0)
)) %>%
add_object(sphere(
x = -10,
y = 0,
z = 0,
material=light(intensity=50))) %>%
render_scene(
samples = 300,
aperture = 0,
lookfrom = c(0, 1, 20),
parallel = TRUE,
width = 800,
height = 800,
sample_method = "sobol",
filename = "renderings/universe_artsy.png"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment