Struct libredr::PyLibreDR

source ·
pub struct PyLibreDR(pub(crate) LibreDR, pub(crate) String, pub(crate) bool, pub(crate) bool);
Expand description

Python interface for LibreDR client

Tuple Fields§

§0: LibreDR§1: String§2: bool§3: bool

Implementations§

source§

impl PyLibreDR

source

pub const MISS_NONE: u8 = 0u8

See render::MISS_NONE for details.

source

pub const MISS_ENVMAP: u8 = 1u8

See render::MISS_ENVMAP for details.

source

pub const REFLECTION_NORMAL_FACE: u8 = 0u8

source

pub const REFLECTION_NORMAL_VERTEX: u8 = 1u8

source

pub const REFLECTION_NORMAL_TEXTURE: u8 = 2u8

source

pub const REFLECTION_DIFFUSE_NONE: u8 = 0u8

source

pub const REFLECTION_DIFFUSE_LAMBERTIAN: u8 = 1u8

source

pub const REFLECTION_SPECULAR_NONE: u8 = 0u8

source

pub const REFLECTION_SPECULAR_PHONG: u8 = 1u8

source

pub const REFLECTION_SPECULAR_BLINN_PHONG: u8 = 2u8

source

pub const REFLECTION_SPECULAR_TORRANCE_SPARROW_PHONG: u8 = 3u8

source

pub const REFLECTION_SPECULAR_TORRANCE_SPARROW_BLINN_PHONG: u8 = 4u8

source

pub const REFLECTION_SPECULAR_TORRANCE_SPARROW_BECKMANN: u8 = 5u8

source

pub fn py_new( py: Python<'_>, connect: String, unix: bool, tls: bool, ) -> Result<Self>

Construct LibreDR by connecting to LibreDR server.

See LibreDR::new for details.

source

pub fn __getnewargs__(&self) -> (String, bool, bool)

To allow pickle PyLibreDR object by reconnecting to the server.

Unpickled connection has different UUID.

source

pub fn py_ray_tracing_forward<'py>( &mut self, py: Python<'py>, geometry: &PyGeometry, ray: PyReadonlyArrayDyn<'_, f32>, texture: PyReadonlyArray3<'_, f32>, envmap: PyReadonlyArray4<'_, f32>, sample_per_pixel: Py<PyAny>, max_bounce: Py<PyAny>, switches: (u8, u8, u8, u8), clip_near: Py<PyAny>, camera_space: bool, requires_grad: bool, srand: i32, low_discrepancy: Option<u32>, ) -> Result<Bound<'py, PyArrayDyn<f32>>>

Create a RequestRayTracingForward task and wait for response

§Arguments
  • ray - ray parameters
    • if camera_space is false 18 * image_shape
      • including ray position 9 * image_shape
      • including ray direction 9 * image_shape
    • if camera_space is true, add another (1 + 14) channels
      • including ray depth 1 * image_shape (if depth <= 0, treat as hit miss)
      • including ray material 14 * image_shape
  • 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_backward)
    • sample_per_pixel can be a single integer,
      • (same value for forward and backward)
    • or tuple of 2 integers.
      • (only sample_per_pixel_backward number of rays are stored for backward)
      • (must ensure sample_per_pixel_forward >= sample_per_pixel_backward)
  • max_bounce - max_bounce_forward, (max_bounce_backward), (max_bounce_low_discrepancy), (skip_bounce)
    • max_bounce can be a single integer, or tuple of 2-4 integers.
    • The default value for max_bounce_backward is the same as max_bounce_forward.
    • The default value for max_bounce_low_discrepancy is 0.
    • The default value for skip_bounce is 0.
  • switches - tuple of 4 switches to determine hit miss and reflection behavior
  • clip_near - clip near distance for camera
    • clip_near can be a single float number (same for all bounces),
    • or tuple of 3 float numbers (first bounce, second bounce, and other bounces)
  • camera_space - if true, the first bounce uses the depth and material given by the ray
  • requires_grad - if true, worker will save intermediate data, the next task must be ray_tracing_backward
  • srand - 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, …
§Return

Return shape will be,

  • if camera_space is true
    • render image 3 * image_shape
  • if camera_space is false, add another
    • ray texture coordinate 2 * image_shape
    • ray depth (Euclidean distance) 1 * image_shape
    • ray normal 3 * image_shape
source

pub fn py_ray_tracing_backward<'py>( &mut self, py: Python<'py>, d_ray: PyReadonlyArrayDyn<'_, f32>, ) -> Result<(Bound<'py, PyArray3<f32>>, Bound<'py, PyArray4<f32>>, Option<Bound<'py, PyArrayDyn<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
§Return

Return shape will be,

Trait Implementations§

source§

impl Debug for PyLibreDR

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for PyLibreDR

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl HasPyGilRef for PyLibreDR

§

type AsRefTarget = PyCell<PyLibreDR>

Utility type to make Py::as_ref work.
source§

impl IntoPy<Py<PyAny>> for PyLibreDR

source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
source§

impl PyClass for PyLibreDR

§

type Frozen = False

Whether the pyclass is frozen. Read more
source§

impl PyClassImpl for PyLibreDR

source§

const IS_BASETYPE: bool = true

#[pyclass(subclass)]
source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<PyLibreDR>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
source§

fn items_iter() -> PyClassItemsIter

source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

source§

impl PyClassNewTextSignature<PyLibreDR> for PyClassImplCollector<PyLibreDR>

source§

fn new_text_signature(self) -> Option<&'static str>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyLibreDR

§

type Holder = Option<PyRef<'py, PyLibreDR>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut PyLibreDR

§

type Holder = Option<PyRefMut<'py, PyLibreDR>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

source§

impl PyMethods<PyLibreDR> for PyClassImplCollector<PyLibreDR>

source§

fn py_methods(self) -> &'static PyClassItems

source§

impl PyTypeInfo for PyLibreDR

source§

const NAME: &'static str = "LibreDR"

Class name.
source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> &PyType

👎Deprecated since 0.21.0: PyTypeInfo::type_object will be replaced by PyTypeInfo::type_object_bound in a future PyO3 version
Returns the safe abstraction over the type object.
§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_type_of will be replaced by PyTypeInfo::is_type_of_bound in a future PyO3 version
Checks if object is an instance of this type or a subclass of this type.
§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_exact_type_of will be replaced by PyTypeInfo::is_exact_type_of_bound in a future PyO3 version
Checks if object is an instance of this type.
§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
source§

impl DerefToPyAny for PyLibreDR

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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