pub struct LibreDR {
connection: Connection,
}Expand description
Rust interface for LibreDR client
Fields§
§connection: ConnectionImplementations§
Source§impl LibreDR
impl LibreDR
Sourcepub async fn new(connect: String, unix: bool, tls: bool) -> Result<Self>
pub async fn new(connect: String, unix: bool, tls: bool) -> Result<Self>
Construct LibreDR by connecting to LibreDR server
Return Error if connection failed\
§Examples
async {
let client_tcp = LibreDR::new(String::from("127.0.0.1:9001"), false, false).await?;
let client_unix = LibreDR::new(String::from("/var/run/libredr_client.sock"), true, false).await?;
}Sourceasync fn try_recv_msg_response_data(
&mut self,
data_cache: &DataCache,
) -> Result<Message>
async fn try_recv_msg_response_data( &mut self, data_cache: &DataCache, ) -> Result<Message>
Receive messages, response RequestData task, until receive a different task
Sourcepub async fn ray_tracing_forward(
&mut self,
geometry: &Geometry,
geometry_data_cache: &DataCache,
ray: ArrayD<f32>,
texture: Array3<f32>,
envmap: Array4<f32>,
sample_per_pixel: (usize, usize),
max_bounce: (usize, usize, usize, usize),
switches: (u8, u8, u8, u8),
clip_near: (f32, f32, f32),
camera_space: bool,
requires_grad: bool,
srand: i32,
low_discrepancy: u32,
) -> Result<ArrayD<f32>>
pub async fn ray_tracing_forward( &mut self, geometry: &Geometry, geometry_data_cache: &DataCache, ray: ArrayD<f32>, texture: Array3<f32>, envmap: Array4<f32>, sample_per_pixel: (usize, usize), max_bounce: (usize, usize, usize, usize), switches: (u8, u8, u8, u8), clip_near: (f32, f32, f32), camera_space: bool, requires_grad: bool, srand: i32, low_discrepancy: u32, ) -> Result<ArrayD<f32>>
Create a RequestRayTracingForward task and wait for response
§Arguments
ray- ray parameters- if
camera_spaceisfalse18 *image_shape- including ray position 9 *
image_shape - including ray direction 9 *
image_shape
- including ray position 9 *
- if
camera_spaceistrue, add another (1 + 14) channels- including ray depth 1 *
image_shape(if depth <= 0, treat as hit miss) - including ray material 14 *
image_shape
- including ray depth 1 *
- if
texture- (3 + 3 + 3 + 1 + 3 + 1) *texture_resolution*texture_resolution(must be square image)- including normal + diffuse + specular + roughness + intensity + window
envmap- 3 * 6 *envmap_resolution*envmap_resolution- (must be box unwrapped 6 square images)
sample_per_pixel-sample_per_pixel_forward,sample_per_pixel_backwardmax_bounce-max_bounce_forward,max_bounce_backward,max_bounce_low_discrepancy,skip_bounceswitches- tuple of 4 switches to determine hit miss and reflection behavior- render::MISS_* - determine how to deal with ray hit miss
- render::REFLECTION_NORMAL_* - determine how to get surface normal
- render::REFLECTION_DIFFUSE_* - determine diffuse reflection model
- render::REFLECTION_SPECULAR_* - determine specular reflection model
common::render::REFLECTION_SPECULAR_NONEcommon::render::REFLECTION_SPECULAR_PHONGcommon::render::REFLECTION_SPECULAR_BLINN_PHONGcommon::render::REFLECTION_SPECULAR_TORRANCE_SPARROW_PHONGcommon::render::REFLECTION_SPECULAR_TORRANCE_SPARROW_BLINN_PHONGcommon::render::REFLECTION_SPECULAR_TORRANCE_SPARROW_BECKMANN
clip_near- clip near distance for cameraclip_nearcan be a single float number (same for all bounces),- or tuple of 3 float numbers (first bounce, second bounce, and other bounces)
camera_space- iftrue, the first bounce uses the depth and material given by the rayrequires_grad- iftrue, worker will save intermediate data, the next task must beray_tracing_backwardsrand- random seed- if srand >= 0, the same random seed is used for every pixel
- if srand < 0, use different seed for each pixel
low_discrepancy- (optional) start id of Halton low discrepancy sequence.- The default value is the same as
sample_per_pixel_forward. - if combine multiple rendered images to reduce noise, this value can be set to:
1 *sample_per_pixel_forward, 2 *sample_per_pixel_forward, 3 *sample_per_pixel_forward, …
- The default value is the same as
§Return
Return shape will be,
- if
camera_spaceistrue- render image 3 *
image_shape
- render image 3 *
- if
camera_spaceisfalse, add another- ray texture coordinate 2 *
image_shape - ray depth (Euclidean distance) 1 *
image_shape - ray normal 3 *
image_shape
- ray texture coordinate 2 *
Sourcepub async fn ray_tracing_backward(
&mut self,
d_ray: ArrayD<f32>,
) -> Result<(Array3<f32>, Array4<f32>, Option<ArrayD<f32>>)>
pub async fn ray_tracing_backward( &mut self, d_ray: ArrayD<f32>, ) -> Result<(Array3<f32>, Array4<f32>, Option<ArrayD<f32>>)>
Create a RequestRayTracingBackward task and wait for response.
Must be called consecutive to a RequestRayTracingForward task with requires_grad set to true.
To create multiple RequestRayTracingForward tasks and backward together, multiple client connections are
required.
§Arguments
d_ray- gradient of image 3 *image_shape(must ensure sameimage_shapeasRequestRayTracingForward)
§Return
Return shape will be,
- if
camera_spaceisfalseforRequestRayTracingForwardtask- 1st return value (3 + 3 + 3 + 1 + 3 + 1) *
texture_resolution*texture_resolution- (same
texture_resolutionasRequestRayTracingForward) - including d_normal + d_diffuse + d_specular + d_roughness + d_intensity + d_window
- (same
- 2nd return value 3 * 6 *
envmap_resolution*envmap_resolution- (same
envmap_resolutionasRequestRayTracingForward) - including d_envmap
- (same
- 1st return value (3 + 3 + 3 + 1 + 3 + 1) *
- if
camera_spaceistrueforRequestRayTracingForwardtask, add another- 3rd return value 14 *
image_shape(same shape asRequestRayTracingForward)- including d_ray_texture
- 3rd return value 14 *
Sourcepub async fn close(&mut self) -> Result<()>
pub async fn close(&mut self) -> Result<()>
Send Message::Close to server to close cleanly
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LibreDR
impl RefUnwindSafe for LibreDR
impl Send for LibreDR
impl Sync for LibreDR
impl Unpin for LibreDR
impl UnwindSafe for LibreDR
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.