Skip to main content

Crate brepkit_render

Crate brepkit_render 

Source
Expand description

Offscreen GPU renderer for brepkit B-Rep solids.

render_solid_offscreen tessellates a Solid and rasterizes it to images with wgpu, entirely off-screen (render to texture + read back). No window or display is required, so it runs in headless CI given any wgpu adapter — a real GPU or a software fallback (e.g. Mesa lavapipe via the Vulkan backend).

§Outputs

Each render produces a shaded color image plus a parallel face-id buffer: every pixel carries the FaceId of the face drawn there (0 = background). Use RenderOutput::face_id_at for pixel picking.

§Precision (render-relative-to-center)

Geometry is tessellated in f64. To keep f32 GPU coordinates accurate even for models far from the origin, vertex positions are uploaded relative to the model’s AABB center; the f64 center is folded into the camera’s view matrix on the CPU.

§Example

use brepkit_render::{Camera, RenderOpts, render_solid_offscreen};
use brepkit_math::vec::{Point3, Vec3};
use brepkit_topology::Topology;

let mut topo = Topology::new();
let solid = brepkit_operations::primitives::make_box(&mut topo, 20.0, 20.0, 20.0)?;
let cam = Camera {
    eye: Point3::new(60.0, 50.0, 70.0),
    target: Point3::new(10.0, 10.0, 10.0),
    up: Vec3::new(0.0, 0.0, 1.0),
    fov_y: 45.0_f64.to_radians(),
    aspect: 1.0,
    near: 0.1,
    far: 1000.0,
};
let opts = RenderOpts::new(512, 512);
let out = render_solid_offscreen(&topo, solid, &cam, &opts)?;
out.color.save("box.png")?;

Structs§

Camera
A perspective camera defined in world space (all coordinates in f64).
CylinderDescriptor
A cylinder surface packed for GPU evaluation.
RenderOpts
Options controlling an offscreen render.
RenderOutput
The result of an offscreen render.
TessFactor
Tessellation factor (level of detail) for the compute mesher.

Enums§

RenderError
Errors that can occur while rendering a solid offscreen.

Constants§

DEFAULT_DEFLECTION
Default linear chord tolerance used when RenderOpts does not override it.
DEFAULT_TARGET_PX
Default screen-space chord-error budget, in pixels.

Functions§

extract_cylinder_descriptor
Extract a CylinderDescriptor from a cylindrical face.
probe_adapter
Probe whether any wgpu adapter (real GPU first, then software fallback) can be obtained on this machine.
render_cylinder_compute_offscreen
Render a compute-meshed cylinder offscreen to a shaded color image + face-id buffer.
render_cylinder_compute_screen_lod
Render a compute-meshed cylinder with the tessellation chosen automatically from its projected screen size (view-dependent LOD).
render_solid_offscreen
Render a solid offscreen to a shaded color image and a face-id buffer.
screen_space_tess_factor
Derive a TessFactor from the cylinder’s projected screen size so the silhouette’s chord error stays within target_px pixels at the given view.