pub struct VolumeRenderer { /* private fields */ }Expand description
A fully GPU-resident volume renderer.
The renderer stores the uploaded 3D texture plus the metadata needed for
raycasting and reslicing. Call VolumeRenderer::set_render_params after
uploading a volume to bake the active transfer functions.
Implementations§
Source§impl VolumeRenderer
impl VolumeRenderer
Sourcepub fn new(device: &Device, queue: &Queue, output_format: TextureFormat) -> Self
pub fn new(device: &Device, queue: &Queue, output_format: TextureFormat) -> Self
Create a new renderer for the given device and output format.
Sourcepub fn from_arc(
device: Arc<Device>,
queue: Arc<Queue>,
output_format: TextureFormat,
) -> Self
pub fn from_arc( device: Arc<Device>, queue: Arc<Queue>, output_format: TextureFormat, ) -> Self
Create a renderer from Arc-wrapped device and queue.
Sourcepub fn output_format(&self) -> TextureFormat
pub fn output_format(&self) -> TextureFormat
The texture format this renderer outputs into.
Sourcepub fn set_volume(&mut self, volume: &DynVolume, linear_interpolation: bool)
pub fn set_volume(&mut self, volume: &DynVolume, linear_interpolation: bool)
Upload (or replace) volume data as a 3D GPU texture.
Sourcepub fn allocate_volume(
&mut self,
dimensions: UVec3,
spacing: DVec3,
origin: DVec3,
direction: DMat3,
scalar_range: (f64, f64),
linear_interpolation: bool,
)
pub fn allocate_volume( &mut self, dimensions: UVec3, spacing: DVec3, origin: DVec3, direction: DMat3, scalar_range: (f64, f64), linear_interpolation: bool, )
Allocate an empty 3D volume texture for progressive slice uploads.
Sourcepub fn update_volume_slice_i16(
&mut self,
z_index: u32,
pixels: &[i16],
scalar_range: (f64, f64),
) -> Result<(), RenderError>
pub fn update_volume_slice_i16( &mut self, z_index: u32, pixels: &[i16], scalar_range: (f64, f64), ) -> Result<(), RenderError>
Update one signed 16-bit volume slice inside an already allocated texture.
Sourcepub fn set_transfer_function(&mut self, lut: &TransferFunctionLut)
pub fn set_transfer_function(&mut self, lut: &TransferFunctionLut)
Upload a baked transfer-function LUT to the GPU.
Sourcepub fn set_render_params(
&mut self,
params: &VolumeRenderParams,
) -> Result<(), RenderError>
pub fn set_render_params( &mut self, params: &VolumeRenderParams, ) -> Result<(), RenderError>
Bake and upload transfer functions from the current render parameters.
§Errors
Returns RenderError::NoVolume if no volume metadata has been uploaded yet.
Sourcepub fn create_render_target(&self, width: u32, height: u32) -> Texture
pub fn create_render_target(&self, width: u32, height: u32) -> Texture
Create an off-screen render target texture.
Sourcepub fn render_volume(
&self,
encoder: &mut CommandEncoder,
target: &TextureView,
camera: &Camera,
params: &VolumeRenderParams,
viewport: Viewport,
) -> Result<(), RenderError>
pub fn render_volume( &self, encoder: &mut CommandEncoder, target: &TextureView, camera: &Camera, params: &VolumeRenderParams, viewport: Viewport, ) -> Result<(), RenderError>
Render the volume into the given color attachment.
The caller owns the command encoder and submits it.
§Errors
Returns RenderError if prerequisites are missing or the viewport is invalid.
Sourcepub fn render_volume_to_texture(
&self,
encoder: &mut CommandEncoder,
camera: &Camera,
params: &VolumeRenderParams,
width: u32,
height: u32,
) -> Result<Texture, RenderError>
pub fn render_volume_to_texture( &self, encoder: &mut CommandEncoder, camera: &Camera, params: &VolumeRenderParams, width: u32, height: u32, ) -> Result<Texture, RenderError>
Render the volume into a newly-created off-screen texture.
§Errors
Propagates the same errors as Self::render_volume.
Sourcepub fn render_volume_interactive(
&self,
encoder: &mut CommandEncoder,
target: &TextureView,
camera: &Camera,
params: &VolumeRenderParams,
viewport: Viewport,
downsample_factor: u32,
) -> Result<(), RenderError>
pub fn render_volume_interactive( &self, encoder: &mut CommandEncoder, target: &TextureView, camera: &Camera, params: &VolumeRenderParams, viewport: Viewport, downsample_factor: u32, ) -> Result<(), RenderError>
Render the volume at reduced resolution and upscale the result into target.
This is intended for interactive manipulation where responsiveness matters
more than final image quality. Passing 1 disables downsampling.
§Errors
Propagates the same errors as Self::render_volume.
Sourcepub fn render_slice(
&self,
encoder: &mut CommandEncoder,
target: &TextureView,
slice_plane: &SlicePlane,
window_level: &WindowLevel,
viewport: Viewport,
thick_slab: Option<&ThickSlabParams>,
) -> Result<(), RenderError>
pub fn render_slice( &self, encoder: &mut CommandEncoder, target: &TextureView, slice_plane: &SlicePlane, window_level: &WindowLevel, viewport: Viewport, thick_slab: Option<&ThickSlabParams>, ) -> Result<(), RenderError>
Render a 2D reslice (MPR slice) into the given color attachment.
§Errors
Returns RenderError::NoVolume when no volume has been uploaded.
Sourcepub fn render_slice_to_texture(
&self,
encoder: &mut CommandEncoder,
slice_plane: &SlicePlane,
window_level: &WindowLevel,
width: u32,
height: u32,
thick_slab: Option<&ThickSlabParams>,
) -> Result<Texture, RenderError>
pub fn render_slice_to_texture( &self, encoder: &mut CommandEncoder, slice_plane: &SlicePlane, window_level: &WindowLevel, width: u32, height: u32, thick_slab: Option<&ThickSlabParams>, ) -> Result<Texture, RenderError>
Render a slice into a newly-created off-screen texture.
§Errors
Propagates the same errors as Self::render_slice.
Sourcepub fn render_crosshair(
&self,
encoder: &mut CommandEncoder,
target: &TextureView,
viewport: Viewport,
crosshair: &CrosshairParams,
) -> Result<(), RenderError>
pub fn render_crosshair( &self, encoder: &mut CommandEncoder, target: &TextureView, viewport: Viewport, crosshair: &CrosshairParams, ) -> Result<(), RenderError>
Render crosshair overlay lines on a slice viewport.
§Errors
Returns RenderError::ZeroViewport for an empty viewport.
Sourcepub fn render_orientation_marker(
&self,
encoder: &mut CommandEncoder,
target: &TextureView,
camera: &Camera,
viewport: Viewport,
labels: &OrientationLabels,
) -> Result<(), RenderError>
pub fn render_orientation_marker( &self, encoder: &mut CommandEncoder, target: &TextureView, camera: &Camera, viewport: Viewport, labels: &OrientationLabels, ) -> Result<(), RenderError>
Render an orientation marker in the given viewport.
The marker is generated on the CPU as a small RGBA image, then composited over the target with a lightweight textured-quad pass.
§Errors
Returns RenderError::ZeroViewport for an empty viewport.