Builds a scene containing only atom spheres from a PDB or SDF model.
generate_atom_scene(
model,
x = 0,
y = 0,
z = 0,
scale = 1,
center = TRUE,
material = rayrender::glossy,
material_args = list(),
material_vertex = material_list(type = "phong")
)Model extracted from a PDB or SDF file.
Default `0`. X offset, applied after centering.
Default `0`. Y offset, applied after centering.
Default `0`. Z offset, applied after centering.
Default `1`. Amount to scale the inter-atom spacing.
Default `TRUE`. Centers the bounding box of the model.
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`.
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`.
Default `rayvertex::material_list()`. Mesh material. `diffuse`/`ambient` colors and `ambient_intensity` are determined automatically, but all other material properties can be changed.
Raymesh scene containing only the atoms in a molecule/protein.
atom_model = read_sdf(get_example_molecule("benzene"))
# Start with a centered raster atom scene using the default atom colors.
atom_model |>
generate_atom_scene() |>
render_model(
pathtrace = FALSE,
width = 800,
height = 800,
background = "grey15"
)
# This version shifts and scales the same atoms, then uses a diffuse mesh
# material for the spheres before pathtracing.
atom_model |>
generate_atom_scene(
x = -1,
y = 0,
z = 1,
scale = 0.75,
center = TRUE,
material = rayrender::diffuse,
material_args = list(sigma = 0.4)
) |>
render_model(pathtrace = TRUE, width = 800, height = 800, samples = 32)
# The toon material changes only the raster shader. Keeping `center = TRUE`
# makes the result easy to compare to the baseline scene above.
toon_material = rayvertex::material_list(
type = "toon_phong",
toon_levels = 3,
toon_outline_width = 0.08
)
caffeine_model = read_sdf(get_example_molecule("caffeine"))
caffeine_model |>
generate_atom_scene(
center = TRUE,
material_vertex = toon_material
) |>
render_model(
pathtrace = FALSE,
width = 800,
height = 800,
background = "grey15"
)