Renders a top-down orthographic radiance pass of either the current hillshade cache, the current 3D rayshader scene, or a supplied elevation matrix.

Cache fallback messages are disabled by default. Set options(rayshader.verbose_scene_cache = TRUE) to print when cached metadata is reused.

When called with no heightmap, this function uses the cached 2D hillshade heightmap and, when available, the cached hillshade/map texture from the most recent rayshader hillshading chain. Set capture_scene = TRUE to instead render the currently displayed rayshader 3D scene. When a raw matrix is supplied, rayshader builds a temporary surface and applies texture (or a constant color, default "grey50").

This function uses the same lighting controls as render_highquality(), including directional lights and auto-sky generation (lat, long, datetime, sky_sun_elevation, sky_sun_azimuth, sky_altitude, and sky_args), and returns an RGBA array that can be passed to add_overlay(). The render runs in an isolated background R session with RGL_USE_NULL=TRUE in the subprocess environment, and uses the standard rayshader pipeline: plot_3d(..., solid = TRUE, shadow = shadow) followed by render_highquality(plot = FALSE).

radiance_shade(
  heightmap = NULL,
  texture = NULL,
  color = "grey50",
  zscale = 1,
  vertical_exaggeration = 1,
  filename = NA,
  samples = 128,
  sample_method = "sobol_blue",
  min_variance = 1e-07,
  shadow = TRUE,
  light = TRUE,
  lat = NA,
  long = NA,
  datetime = NA,
  sky_sun_elevation = NA,
  sky_sun_azimuth = NA,
  sky_altitude = NA,
  sky_args = list(),
  light_direction = 315,
  light_altitude = 45,
  light_size = 5,
  light_intensity = 500,
  light_color = "white",
  material = rayrender::diffuse(),
  water_attenuation = 0,
  water_surface_color = TRUE,
  water_ior = 1.33,
  override_material = FALSE,
  cache_scene = FALSE,
  reset_scene_cache = FALSE,
  width = NULL,
  height = NULL,
  clamp_value = 1000,
  auto_exposure = TRUE,
  capture_scene = FALSE,
  scene_elements = NULL,
  plot = FALSE,
  geographic_aspect = TRUE,
  extent = NULL,
  crs = NULL,
  ...
)

Arguments

heightmap

Default NULL. If NULL, uses cached 2D hillshade metadata by default. Set capture_scene = TRUE to use the current rayshader rgl scene. If a matrix (or supported raster input), renders a top-down radiance pass for that data directly.

texture

Default NULL. Texture used only when heightmap is supplied. Can be a rayshader-style RGB(A) array, a built-in sphere_shade() texture name, a color vector (passed to height_shade()), an image filename, or a single color name.

color

Default "grey50". Fallback single-color texture when heightmap is supplied and texture = NULL.

zscale

Default 1. Vertical scale when heightmap is supplied.

vertical_exaggeration

Default 1. Multiplier applied to the effective visual relief. If omitted while rendering from the active scene, rayshader uses the cached scene value from plot_3d() or plot_gg() when available; pass explicitly to override for this call. This does not update cached metadata.

filename

Default NA. Optional output filename. If supplied, the render is also saved to disk.

samples

Default 128. Maximum samples per pixel.

sample_method

Default "sobol_blue", unless samples > 256, in which case it is switched to "sobol".

min_variance

Default 1e-7. Adaptive sampler variance threshold.

shadow

Default TRUE. Whether to build the temporary top-down scene with the rayshader shadow plane underneath the model. Setting this to TRUE can help fill very dark corners in the radiance pass.

light

Default TRUE. Whether to add directional lights.

lat

Default NA. Latitude used for auto sky generation.

long

Default NA. Longitude used for auto sky generation.

datetime

Default NA. Datetime used for auto sky generation.

sky_sun_elevation

Default NA. If supplied, uses skymodelr::generate_sky() and passes this value to its elevation argument.

sky_sun_azimuth

Default NA. If supplied, uses skymodelr::generate_sky() and passes this value to its azimuth argument.

sky_altitude

Default NA. If supplied, uses skymodelr::generate_sky() and passes this value to its altitude argument.

sky_args

Default list(). Extra arguments passed to skymodelr::generate_sky_latlong() (default) or skymodelr::generate_sky() when direct sky arguments are used.

light_direction

Default 315. Light direction angle(s), in degrees.

light_altitude

Default 45. Light altitude angle(s), in degrees.

light_size

Default 5. Full angular diameter of the disk light(s), in degrees, greater than 0 and less than 180. Independent of scene size and camera position.

light_intensity

Default 500. Light intensity value(s).

light_color

Default "white". Light color(s).

material

Default rayrender::diffuse(). Forwarded to render_highquality().

water_attenuation

Default 0. Forwarded to render_highquality().

water_surface_color

Default TRUE. Forwarded to render_highquality().

water_ior

Default 1.33. Forwarded to render_highquality().

override_material

Default FALSE. Forwarded to render_highquality().

cache_scene

Default FALSE. Forwarded to render_highquality().

reset_scene_cache

Default FALSE. Forwarded to render_highquality().

width

Default NULL. Output width in pixels. If omitted, derived from the underlying surface dimensions.

height

Default NULL. Output height in pixels. If omitted, derived from the underlying surface dimensions.

clamp_value

Default 1000. Radiance clamp value. If NA, uses 1000.

auto_exposure

Default TRUE. Whether to use rayrender's automatic exposure adjustment in the radiance pass. Forwarded to rayrender::render_scene() via render_highquality() when supported by the installed rayrender version.

capture_scene

Default FALSE. If TRUE and heightmap = NULL, renders the currently displayed rayshader rgl scene instead of the cached 2D hillshade context.

scene_elements

Default NULL. Extra rayrender objects to add.

plot

Default FALSE. Whether to preview the rendered image.

geographic_aspect

Default TRUE. Correct unequal metric x/y cell spacing in the temporary radiance scene.

extent

Default NULL. Spatial extent for a matrix heightmap.

crs

Default NULL. CRS to assign to the input before calculating metric cell spacing.

...

Additional parameters passed to render_highquality(). Deprecated argument spellings are accepted with a warning and forwarded to their current names.

Value

RGBA array representing the top-down radiance render.

Examples

montereybay_spatial |>
height_shade(texture = topo.colors(256)) |>
add_overlay(radiance_shade(vertical_exaggeration = 10), 1) |>
plot_map()

#Plot using sky args
montereybay_spatial |>
height_shade(texture = topo.colors(256)) |>
add_overlay(radiance_shade(vertical_exaggeration = 20,
                            sky_sun_elevation = 5, sky_sun_azimuth = 315), 1) |>
plot_map()