euv-core 0.57.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Physically based ray-tracing material supporting Lambert/Oren-Nayar, GGX metal, clearcoat, dielectric glass/water with Beer-Lambert absorption, and area emission.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct RtMaterial {
    /// Active physical BSDF family.
    #[get(type(copy))]
    pub(crate) kind: RtMaterialKind,
    /// Linear base RGB reflectance / transmittance tint in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) albedo: Vec3,
    /// Conductor blend weight in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) metallic: f32,
    /// Perceptual microfacet roughness in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) roughness: f32,
    /// Dielectric index of refraction (`1.5` glass, `1.333` water).
    #[get(type(copy))]
    pub(crate) ior: f32,
    /// Dielectric transmission weight in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) transmission: f32,
    /// Beer-Lambert volumetric absorption coefficient `sigma_a` (`1 / meters`) attenuating transmitted rays by `exp(-sigma_a * distance)`.
    #[get(type(copy))]
    pub(crate) absorption: Vec3,
    /// Dielectric clearcoat top-layer weight in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) clearcoat: f32,
    /// Clearcoat top-layer roughness in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) clearcoat_roughness: f32,
    /// Emitted linear HDR RGB radiance.
    #[get(type(copy))]
    pub(crate) emission: Vec3,
    /// Oren-Nayar micro-surface diffuse roughness standard deviation in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) oren_nayar_sigma: f32,
}

/// Physical scene light combining emitter geometry with linear HDR color and intensity.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct RtLight {
    /// Emitter geometric shape and orientation.
    #[get(type(copy))]
    pub(crate) kind: RtLightKind,
    /// Linear HDR RGB chromaticity color.
    #[get(type(copy))]
    pub(crate) color: Vec3,
    /// Scalar radiant intensity or surface radiance multiplier.
    #[get(type(copy))]
    pub(crate) intensity: f32,
}

/// Evaluated direct lighting sample returned by `RtLight::sample_light`.
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct RtLightSample {
    /// Unit direction pointing from the shaded hit point toward the sampled point on the light.
    #[get(type(copy))]
    pub(crate) direction: Vec3,
    /// Distance in meters to the sampled point on the light (`RT_RAY_T_MAX` for directional lights).
    #[get(type(copy))]
    pub(crate) distance: f32,
    /// Incident HDR radiance arriving from the sampled direction (already including inverse-square falloff for delta point/spot lights).
    #[get(type(copy))]
    pub(crate) radiance: Vec3,
    /// Solid-angle sampling probability density `p(omega)` (`1.0` for pure delta lights).
    #[get(type(copy))]
    pub(crate) pdf: f32,
    /// Whether this light sample comes from a Dirac delta distribution (exempt from BSDF MIS).
    #[get(type(copy))]
    pub(crate) is_delta: bool,
}

/// Pinhole and Thin-Lens Depth-of-Field camera generating jittered primary rays for anti-aliasing and bokeh defocus.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct RtCamera {
    /// World-space eye / lens center position.
    #[get(type(copy))]
    pub(crate) position: Vec3,
    /// Unit forward look direction.
    #[get(type(copy))]
    pub(crate) forward: Vec3,
    /// Unit horizontal right basis vector.
    #[get(type(copy))]
    pub(crate) right: Vec3,
    /// Unit vertical up basis vector.
    #[get(type(copy))]
    pub(crate) up: Vec3,
    /// Vertical field of view in radians.
    #[get(type(copy))]
    pub(crate) fov_y_rad: f32,
    /// Viewport width-to-height aspect ratio.
    #[get(type(copy))]
    pub(crate) aspect: f32,
    /// Thin-lens aperture radius in meters (`0.0` = sharp pinhole camera).
    #[get(type(copy))]
    pub(crate) aperture_radius: f32,
    /// Distance in meters from lens plane to the plane of sharp focus.
    #[get(type(copy))]
    pub(crate) focal_distance: f32,
}

/// Complete ray-traceable 3D scene holding BLAS/TLAS geometry, analytic primitives, SDF volumes, materials, lights, sky environment, and camera.
#[derive(Clone, Data, Debug)]
pub struct RaytraceScene {
    /// Shared local-space triangle BLAS table referenced by `RtInstance::blas_id`.
    pub(crate) blas_list: Vec<Blas3D>,
    /// Dynamic top-level acceleration structure over all instanced meshes.
    pub(crate) tlas: Tlas3D,
    /// Analytic primitives intersected directly without tessellation.
    pub(crate) primitives: Vec<RtPrimitive>,
    /// Implicit SDF/CSG volumes evaluated via Lipschitz sphere tracing.
    pub(crate) sdf_tracers: Vec<SdfSphereTracer>,
    /// Material table referenced by `material_id` across instances, primitives, and SDFs.
    pub(crate) materials: Vec<RtMaterial>,
    /// Physical scene light emitters sampled by direct lighting and MIS NEE.
    pub(crate) lights: Vec<RtLight>,
    /// Environment dome evaluated when rays escape all geometry.
    #[get(type(copy))]
    pub(crate) environment: RtEnvironment,
    /// Active thin-lens or pinhole ray-tracing camera.
    #[get(type(copy))]
    pub(crate) camera: RtCamera,
    /// Monotonic revision bumped whenever scene geometry, materials, lights, or environment mutate.
    #[get(type(copy))]
    pub(crate) revision: u64,
}

/// Fluent scene builder and curated preset generator for `RaytraceScene`.
#[derive(Clone, Data, Debug)]
pub struct RaytraceSceneBuilder {
    /// Scene under construction.
    pub(crate) scene: RaytraceScene,
}