-
SummaryThe example here uses code like: N = 100
theta = dr.linspace(mi.Float, 0.0, dr.two_pi, N) This results in System configurationN/A DescriptionStarting to use mitsuba and drjit. I was trying to load a mesh using trimesh (it supports more file formats, including .stl) and couldn't figure out how to convert it. In case others might find this useful, this works: import trimesh
import mitsuba as mi
import numpy as np
tmesh = trimesh.load(stlfile)
mesh = mi.Mesh("mesh_name",
vertex_count=tmesh.vertices.shape[0],
face_count=tmesh.faces.shape[0],
has_vertex_normals=True)
mesh_params = mi.traverse(mesh)
mesh_params['vertex_positions'] = np.asarray(tmesh.vertices).ravel()
mesh_params['faces'] = np.asarray(tmesh.faces).ravel()
mesh_params['vertex_normals'] = np.asarray(tmesh.vertex_normals).ravel() That documentation example made me misunderstand the different types present in mitsuba. It made me think I needed the LLVM version to be able to use arrays like this, but that seems wrong. I also thought Array3f would hold Nx3 or 3xN, so arrays of triplets/vectors, but apparently that's wrong and it literally holds 3 values. Would be great if someone could clarify the basics of the type system a bit more (and update the example in the docs). Steps to reproduceN/A |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
To further illustrate the point, this was very counter-intuitive to me:
|
Beta Was this translation helpful? Give feedback.
-
Hi @tomas16 The notebook/guide you refer to uses the LLVM backend ( I'd stongly recommend looking at the Dr.Jit introduction documentation to get a better intuition for the difference between vectorization width and array length. As you've pointed out, one can use the |
Beta Was this translation helpful? Give feedback.
-
Hi @njroussel, thanks for clearing some of that up. I think I got confused somewhere along the way. I'm used to numpy/matlab style of scientific programming. I guess that kind of maps to the llvm variant so I should probably use that. I thought I'd start with the scalar version and switch to llvm later (I had some deployment issues related to using libLLVM). A few more questions:
|
Beta Was this translation helpful? Give feedback.
(I've converted this to a discussion thread, it seemed more appropriate)
This is partially true. Most of the C++ Mitsuba source code is only written "once". We do however have some snippets where the scalar case is handled explicitly.
To partially continue my answer to 1): the example you point is exactly how you can get around writing code "twice". You consider a
scalar.ArrayXf
to be similar/equivalent to acuda.Float
. I do think that the typing system in Python is not exhaustive enough to allow you to fully write your code with thisArrayXf
approach. For example, I don't think it's possible to have an equivalent tollvm.Array2f
in Python and in scalar modes where you'd actually wants…