Builds a combined atom and bond scene from a PDB or SDF model.

generate_full_scene(
  model,
  x = 0,
  y = 0,
  z = 0,
  scale = 1,
  center = TRUE,
  force_single_bonds = FALSE,
  material = rayrender::glossy,
  material_args = list(),
  material_vertex = material_list(type = "phong")
)

Arguments

model

Model extracted from a PDB or SDF file.

x

Default `0`. X offset, applied after centering.

y

Default `0`. Y offset, applied after centering.

z

Default `0`. Z offset, applied after centering.

scale

Default `1`. Amount to scale the interatom spacing.

center

Default `TRUE`. Centers the bounding box of the model.

force_single_bonds

Default `FALSE`. Whether to force all bonds to show as a single connection.

material

Default `rayrender::glossy`. Optional rayrender material used to initialize the mesh material when `material_vertex` is not supplied. Must be either `glossy`, `diffuse`, or `dielectric`.

material_args

Default `list()`. Named list of additional arguments passed to `material`. Arguments supplied by raymolecule for colors and textures override entries with the same names. For example, use `list(gloss = 0.35, reflectance = 0.12)` with `rayrender::glossy`, or `list(sigma = 0.4)` with `rayrender::diffuse`.

material_vertex

Default `rayvertex::material_list()`. Mesh material. `diffuse`/`ambient` colors and `ambient_intensity` are determined automatically, but all other material properties can be changed.

Value

Raymesh scene

Examples

molecule_model = read_sdf(get_example_molecule("caffeine"))

# Start with a centered raster scene that combines atom spheres and bond
# geometry using the default atom colors.
molecule_model |>
  generate_full_scene(force_single_bonds = TRUE) |>
  render_model(
    pathtrace = FALSE,
    width = 800,
    height = 800,
    background = "grey12"
  )


# This version changes the scale, keeps the model centered, and uses a
# diffuse mesh material for both atoms and bonds before pathtracing.
molecule_model |>
  generate_full_scene(
    x = 0,
    y = 0,
    z = 0,
    scale = 0.75,
    center = TRUE,
    force_single_bonds = TRUE,
    material = rayrender::diffuse,
    material_args = list(sigma = 0.3)
  ) |>
  render_model(pathtrace = TRUE, width = 800, height = 800, samples = 32)


# A toon material changes the raster shader and pass FSAA to render_model()
# so rayvertex adds anti-aliasing.
shiny_toon_material = rayvertex::material_list(
  type = "toon_phong",
  toon_levels = 3,
  toon_outline_width = 10,
  toon_outline_color = "white"
)
morphine_model = read_sdf(get_example_molecule("morphine"))
morphine_model |>
  generate_full_scene(
    material_vertex = shiny_toon_material
  ) |>
  render_model(
    fsaa = 2,
    pathtrace = FALSE,
    width = 800,
    height = 800,
    background = "grey50"
  )