Learn R Programming

rayrender (version 0.41.3)

generate_cornell: Generate Cornell Box

Description

Generate Cornell Box

Usage

generate_cornell(
  light = TRUE,
  lightintensity = 5,
  lightcolor = "white",
  lightwidth = 332,
  lightdepth = 343,
  light_position = c(555/2, 554, 555/2),
  sigma = 0,
  leftcolor = "#1f7326",
  rightcolor = "#a60d0d",
  roomcolor = "#bababa",
  importance_sample = TRUE
)

Value

Tibble containing the scene description of the Cornell box.

Arguments

light

Default `TRUE`. Whether to include a light on the ceiling of the box.

lightintensity

Default `5`. The intensity of the light.

lightcolor

Default `white`. The color the of the light.

lightwidth

Default `332`. Width (z) of the light.

lightdepth

Default `343`. Depth (x) of the light.

light_position

Default `c(555/2,554,555/2)`. Position of the light.

sigma

Default `0`. Oren-Nayar microfacet angle.

leftcolor

Default `#1f7326` (green).

rightcolor

Default `#a60d0d` (red).

roomcolor

Default `#bababa` (light grey).

importance_sample

Default `TRUE`. Importance sample the light in the room.

Examples

Run this code
if (FALSE) { # interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
#Generate and render the default Cornell box.
render_scene(generate_cornell(),
             samples=16,aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)
#Make a much smaller light in the center of the room.
render_scene(generate_cornell(lightwidth=200,lightdepth=200),
             samples=16,aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)
#Place a sphere in the middle of the box.
scene = generate_cornell(lightwidth=200,lightdepth=200) |>
  add_object(sphere(x=555/2,y=555/2,z=555/2,radius=555/4))
render_scene(scene, samples=16,aperture=0, fov=40, ambient_light=FALSE, parallel=TRUE)
#Reduce "fireflies" by setting a clamp_value in render_scene()
render_scene(scene, samples=16,aperture=0, fov=40, ambient_light=FALSE,
             parallel=TRUE,clamp_value=3)
# Change the color scheme of the cornell box
generate_cornell(leftcolor="purple", rightcolor="yellow") |>
  render_scene(samples=16,aperture=0, fov=40, ambient_light=FALSE,
               parallel=TRUE,clamp_value=3)
}

Run the code above in your browser using DataLab