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).
- Cylinder
Descriptor - A cylinder surface packed for GPU evaluation.
- Render
Opts - Options controlling an offscreen render.
- Render
Output - The result of an offscreen render.
- Tess
Factor - Tessellation factor (level of detail) for the compute mesher.
Enums§
- Render
Error - Errors that can occur while rendering a solid offscreen.
Constants§
- DEFAULT_
DEFLECTION - Default linear chord tolerance used when
RenderOptsdoes not override it. - DEFAULT_
TARGET_ PX - Default screen-space chord-error budget, in pixels.
Functions§
- extract_
cylinder_ descriptor - Extract a
CylinderDescriptorfrom 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
TessFactorfrom the cylinder’s projected screen size so the silhouette’s chord error stays withintarget_pxpixels at the given view.