diffrp.scene.objects#

class diffrp.scene.objects.MeshObject(material: SurfaceMaterial, verts: Tensor, tris: IntTensor, normals: Literal['flat', 'smooth'] | Tensor = 'flat', M: Tensor | None = None, color: Tensor | None = None, uv: Tensor | None = None, tangents: Tensor | None = None, custom_attrs: Dict[str, Tensor] | None = None, metadata: Dict[str, Any] | None = None)#

Bases: object

Represents a triangle mesh object in the scene.

Parameters:
  • material (SurfaceMaterial) – The material to render with. You can use the diffrp.materials.default_material.DefaultMaterial if you only care about the triangle geometry.

  • verts (torch.Tensor) – GPU tensor of vertices. Tensor of shape (V, 3), dtype float32.

  • tris (torch.IntTensor) – GPU tensor of indices. Tensor of shape (F, 3), dtype int32.

  • normals (torch.Tensor or str) – GPU tensor of vertex normals. Tensor of shape (V, 3), dtype float32. Alternatively, you can specify ‘flat’ or ‘smooth’ here. Automatic normals with flat or smooth faces will be computed. Defaults to ‘flat’.

  • M (torch.Tensor) – Model matrix, or pose transform of the object. Tensor of shape (4, 4), dtype float32. Defaults to identity.

  • colors (torch.Tensor) – Linear-space RGBA vertex colors, in range [0, 1]. Tensor of shape (V, 4), dtype float32. Defaults to white (all ones).

  • uv (torch.Tensor) – UV coordinates of vertices. Tensor of shape (V, 2), dtype float32. Defaults to zeros.

  • tangents (torch.Tensor) – Tangent spaces of vertices. Tensor of shape (V, 4), dtype float32. The first 3 dimensions are the tangent vector. The last dimension is sign of the bitangent. Defaults to zeros.

  • custom_attrs (Dict[str, torch.Tensor]) – Arbitrary attributes you want to bind to your vertices. Tensor of shape (V, *) for each attribute, dtype float32.

  • metadata (Dict[str, Any]) – Arbitrary meta data to tag the object. Not used for rendering.

M: Tensor | None = None#
__init__(material: SurfaceMaterial, verts: Tensor, tris: IntTensor, normals: Literal['flat', 'smooth'] | Tensor = 'flat', M: Tensor | None = None, color: Tensor | None = None, uv: Tensor | None = None, tangents: Tensor | None = None, custom_attrs: Dict[str, Tensor] | None = None, metadata: Dict[str, Any] | None = None) None#
color: Tensor | None = None#
custom_attrs: Dict[str, Tensor] | None = None#
material: SurfaceMaterial#
metadata: Dict[str, Any] | None = None#
normals: Literal['flat', 'smooth'] | Tensor = 'flat'#
preprocess()#
tangents: Tensor | None = None#
tris: IntTensor#
uv: Tensor | None = None#
verts: Tensor#