Records (PyTorch)
Input and result dataclasses of rayd.torch - intersections, edges, visibility, reflection, accumulation, materials, and diffraction.
rayd.torch exchanges data through dataclasses of tensors. Result records are frozen. Shapes use N for the batch, k for top-k slots, and B for max_bounces. Complex quantities are stored as separate real and imaginary tensors (..._re, ..._im).
Ray query results#
Intersection#
| Field | Shape | Meaning |
|---|---|---|
t | (N,) | hit distance in units of d; inf on a miss |
p | (N, 3) | hit point |
n | (N, 3) | shading normal |
geo_n | (N, 3) | geometric normal |
uv | (N, 2) | texture coordinate |
barycentric | (N, 3) | barycentric coordinates |
shape_id | (N,) | mesh or instance id; -1 on a miss |
prim_id, local_prim_id | (N,) | triangle index within the mesh |
global_prim_id | (N,) | scene-global triangle index |
Property instance_id and method is_valid() -> Tensor (the hit mask).
NearestPointEdge#
distance (N,), edge_point (N, 3), edge_t (N,), shape_id, edge_id, global_edge_id (N,). Unlike the Dr.Jit record, it has no point or is_boundary field.
NearestRayEdge#
distance, ray_t, point (closest point on the ray), edge_t, edge_point, shape_id, edge_id, global_edge_id.
NearestEdgesTopK#
query_count, k, and (N, k) tensors is_valid, distances, points, edge_t, edge_points, shape_ids, edge_ids, global_edge_ids, is_boundary.
Visibility#
| Record | Fields |
|---|---|
SegmentPairVisibility | ray_count, visible_a, visible_b |
AxialEdgeVisibility | state_count, any_visible |
SegmentChainVisibility | chain_count, max_segments, all_visible, first_blocked_segment, first_blocked_prim |
Scene.visible returns a bool tensor, not a record.
SceneGlobalGeometry#
vertices, faces, face_normal, shape_id, local_prim_id, global_prim_id for all world-space triangles.
Reflection#
ReflectionChain#
| Field | Shape | Meaning |
|---|---|---|
valid | (N, B) | slot holds a reflection |
t | (N, B) | distance from the previous point; 1e8 in invalid slots |
image_sources | (N, B, 3) | image source per bounce |
prim_ids | (N, B) | reflector id; -1 in invalid slots |
ReflEpcOptions#
ReflEpcOptions(expected_prim_ids, direct_plane_points, direct_plane_normals, surface_group_id,
surface_group_size, surface_group_members, visibility_ignore_mode="primitive", plane_tolerance=1e-5)Inputs to Scene.trace_refl_epc: expected reflector per slot, the reflecting planes, and the surface-group tables. See the Dr.Jit ReflEpcOptions for the meaning of each table.
ReflEpc#
ray_count, max_bounces, valid, path_length, resolved_prim_ids, surface_group_ids, hit_points, normals.
ReflEpcField#
field_real, field_imag (the complex field), path_length, valid, resolved_prim_ids.
AccumGrid#
AccumGrid(axis=2, position=0.0, coord0_min=0.0, coord0_max=0.0, coord1_min=0.0, coord1_max=0.0, resolution0=0, resolution1=0)Same meaning as the Dr.Jit AccumGrid.
AccumOptions#
AccumOptions(wavelength=1.0, solid_angle_per_ray=1.0, collect_wedges=False, collect_wedge_prefixes=False,
wedge_capacity=0, wedge_sample_stride=1, accumulation_strategy=0, compact_min_samples=0,
staged_min_samples_per_cell=0, procedural_sample_count=0, include_los=False)wavelength, solid_angle_per_ray, and the wedge fields match the Dr.Jit options. There is no k, cell_area, seed, or Russian-roulette field. accumulation_strategy, compact_min_samples, staged_min_samples_per_cell, procedural_sample_count, and include_los are Torch-only execution settings; the defaults are the reference behavior.
ReflMaterial#
ReflMaterial(eta_r, sigma, mu_r, gain, valid)
ReflMaterial.default(count: int, *, device, dtype=torch.float32) -> ReflMaterialPer-primitive relative permittivity, conductivity, relative permeability, gain, and validity, one entry per scene-global primitive. default(count, device=...) returns eta_r = 1, sigma = 0, mu_r = 1, gain = 1, valid = True.
AccumResult#
ray_count, max_bounces, grid_cell_count, reflection_power, reflection_field_x_re, reflection_field_x_im (and _y, _z), reflection_count, wedge_events. Properties reflection_field_x, reflection_field_y, reflection_field_z return complex tensors.
WedgeEvents#
capacity, count, ray_index, hit_points, normals, prim_id, directions, source_points, src_power, initial_directions, bounce_depth.
Diffraction#
DfrStates#
DfrStates(edge_index, edge_pos, edge_dir, edge_t_min, edge_t_max, n0, n1, prim0, prim1,
exterior_angle, src, src_power, wi=None, d0=None, count=None)One row per wedge and source; fields as in the Dr.Jit DfrStates. state_count returns the row count. with_default_vectors() returns a copy with missing wi and d0 filled with zeros.
DfrGrid#
DfrGrid(axis=2, position=0.0, coord0_min=-1.0, coord0_max=1.0, coord1_min=-1.0, coord1_max=1.0,
resolution0=1, resolution1=1, cell_area=None)cell_area=None derives the area as the grid extent divided by resolution0 * resolution1; resolved_cell_area() returns the value used. Note the defaults differ from AccumGrid.
DfrMaterial#
DfrMaterial(eta_r, sigma, mu_r, gain, valid)
DfrMaterial.default(count: int, *, device, dtype=torch.float32) -> DfrMaterialDfrPathLayout#
IntEnum that sets the storage order of exported path rows: Compact (0, default) or SourceLane (1, rows kept in transmitter-aligned blocks).
DfrAccum#
grid_cell_count, power, field_x_re, field_x_im, field_y_re, field_y_im, field_z_re, field_z_im, direct_count, keller_count, suffix_count, vis_rejects, edge_vis_rejects, utd_rejects, edge_uses.
DfrCoherentAccum#
grid_cell_count, direct_field_*_re / _im and multi_field_*_re / _im for x, y, z, plus direct_count, multi_count, visibility_reject_count, utd_reject_count.
DfrPaths#
capacity, count, valid, tx_id, rx_id, order, edge0, edge1, edge2, delay, field_x_re / _im (and _y, _z), p0, p1, p2, and layout.