Skip to main content

VolumeRenderer

Struct VolumeRenderer 

Source
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

Source

pub fn new(device: &Device, queue: &Queue, output_format: TextureFormat) -> Self

Create a new renderer for the given device and output format.

Source

pub fn from_arc( device: Arc<Device>, queue: Arc<Queue>, output_format: TextureFormat, ) -> Self

Create a renderer from Arc-wrapped device and queue.

Source

pub fn output_format(&self) -> TextureFormat

The texture format this renderer outputs into.

Source

pub fn set_volume(&mut self, volume: &DynVolume, linear_interpolation: bool)

Upload (or replace) volume data as a 3D GPU texture.

Source

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.

Source

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.

Source

pub fn set_transfer_function(&mut self, lut: &TransferFunctionLut)

Upload a baked transfer-function LUT to the GPU.

Source

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.

Source

pub fn resize(&mut self, width: u32, height: u32)

Handle viewport resize.

Source

pub fn create_render_target(&self, width: u32, height: u32) -> Texture

Create an off-screen render target texture.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,