nanovdb_medium: NanoVDB Participating Medium

View source: R/media.R

nanovdb_mediumR Documentation

NanoVDB Participating Medium

Description

Read uncompressed float grids from a NanoVDB file. Native grid coordinates and transforms are retained; use 'medium_transform' to place them inside the boundary. Convert OpenVDB or compressed NanoVDB files externally before use.

Usage

nanovdb_medium(
  filename,
  sigma_a = 0,
  sigma_s = 1,
  density_scale = 1,
  g = 0,
  density_grid = "density",
  temperature_grid = NULL,
  emission = 0,
  emission_scale = 1,
  temperature_scale = 1,
  temperature_offset = 0,
  medium_transform = diag(4),
  haze = TRUE,
  haze_density_threshold = NULL
)

Arguments

filename

Path to an uncompressed '.nvdb' file.

sigma_a

Default '0'. Absorption coefficient, a nonnegative number or RGB vector, per world-space distance unit.

sigma_s

Default '1'. Scattering coefficient, a nonnegative number or RGB vector, per world-space distance unit.

density_scale

Default '1'. Nonnegative multiplier for both coefficients.

g

Default '0'. Henyey-Greenstein asymmetry, strictly between -1 and 1. Positive values scatter forward along the incident light direction.

density_grid

Default '"density"'. Name of the float density grid.

temperature_grid

Default 'NULL'. Optional float temperature grid name.

emission

Default '0'. Nonnegative scalar or RGB emitted radiance 'Le'. Color names are also accepted. The volume source is 'sigma_a * Le'.

emission_scale

Default '1'. Nonnegative multiplier for emitted radiance.

temperature_scale

Default '1'. Nonnegative multiplier applied after subtracting 'temperature_offset' from the temperature.

temperature_offset

Default '0'. Offset subtracted from temperatures.

medium_transform

Default 'diag(4)'. Invertible affine matrix mapping medium coordinates into the containing object's local coordinates.

haze

Default 'TRUE'. Include clear-air atmospheric haze inside this medium when enabled by [sky_light()], subject to 'haze_density_threshold'. Set 'FALSE' to skip its atmospheric in-scattering and extinction throughout the entire boundary, including empty cells, regardless of the threshold. The medium's own scattering, absorption, and emission remain active. In nested media the innermost medium's setting applies; 'sky_light(haze_in_volumes = FALSE)' overrides all media. This is an approximation and may affect thin clouds, edges, or low-altitude haze.

haze_density_threshold

Default 'NULL'. With 'haze = TRUE', omit haze only where interpolated density times 'density_scale' is at least this positive number. Lower-density regions and empty space retain haze. A homogeneous medium has density one before scaling. 'NULL' includes haze throughout the boundary. Ignored with 'haze = FALSE' or global haze exclusion. The threshold measures density, not optical depth or scattering strength; choose which media to tag accordingly. Crossings follow the trilinear field, including between scattering events, and transform with the medium.

Value

A reusable 'ray_medium' description. Files are loaded during scene construction.


rayrender documentation built on Sept. 16, 2026, 9:08 a.m.