Struct PyLibreDR

Source
pub struct PyLibreDR(/* private fields */);
Expand description

Python interface for LibreDR client

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 IntoPy<Py<PyAny>> for PyLibreDR

Source§

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

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23.0/migration) for more information.
Performs the conversion.
Source§

impl<'py> IntoPyObject<'py> for PyLibreDR

Source§

type Target = PyLibreDR

The Python output type
Source§

type Output = Bound<'py, <PyLibreDR as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

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

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for PyLibreDR

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassBaseType for PyLibreDR

Source§

type LayoutAsBase = PyClassObject<PyLibreDR>

Source§

type BaseNativeType = <PyLibreDR as PyClassImpl>::BaseNativeType

Source§

type Initializer = PyClassInitializer<PyLibreDR>

Source§

type PyClassMutability = <PyLibreDR as PyClassImpl>::PyClassMutability

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)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<PyLibreDR>

This handles following two situations: Read more
Source§

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

Immutable or mutable
Source§

type Dict = PyClassDummySlot

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

type WeakRef = PyClassDummySlot

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

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>

Source§

fn dict_offset() -> Option<isize>

Source§

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, false> for &'a PyLibreDR

Source§

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, false> for &'a mut PyLibreDR

Source§

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

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

Returns the safe abstraction over the type object.
Source§

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

👎Deprecated since 0.23.0: renamed to PyTypeInfo::type_object
Deprecated name for PyTypeInfo::type_object.
Source§

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

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

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

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_type_of
Deprecated name for PyTypeInfo::is_type_of.
Source§

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

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

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

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_exact_type_of
Deprecated name for PyTypeInfo::is_exact_type_of.
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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

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

Arguments for exception
Source§

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

Source§

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

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

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

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