Page 1 of 1
Bug in Blender exportation
Posted: Fri Aug 23, 2019 3:44 pm
by lyinch
Hey,
I found something strange when exporting from Blender.
The exporter sets (for a scaled object) the following line:
Code: Select all
scene.objects.Mesh_Sphere_140699409946120000.appliedtransformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
Additionally it generates a .ply file.
However, scene.objects.<>.appliedtransformation is not in the documentation and isn't read by luxcoreui. What the exporter does is save mesth to the ply after applying the transformation. The correct way is to either omit the above mentioned property, or save the mesh in object space (which allows us to use instancing) and use
Code: Select all
scene.objects.Mesh_Sphere_140699409946120000.transformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
I'm also a bit confused about the relation between objects and meshes.
Re: Bug in Blender exportation
Posted: Fri Aug 23, 2019 3:54 pm
by alpistinho
lyinch wrote: Fri Aug 23, 2019 3:44 pm
Code: Select all
scene.objects.Mesh_Sphere_140699409946120000.appliedtransformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
Additionally it generates a .ply file.
However, scene.objects.<>.appliedtransformation is not in the documentation and isn't read by luxcoreui. What the exporter does is save mesth to the ply after applying the transformation. The correct way is to either omit the above mentioned property, or save the mesh in object space (which allows us to use instancing)
I can't really look into the code right now to give you a better answer, but the applied transformation property is defined here:
https://wiki.luxcorerender.org/LuxCore_ ... Type:_mesh
Re: Bug in Blender exportation
Posted: Fri Aug 23, 2019 4:06 pm
by lyinch
appliedtransformation is defined for
and not for
Which is what blender exported in my case
Re: Bug in Blender exportation
Posted: Fri Aug 23, 2019 4:18 pm
by Dade
lyinch wrote: Fri Aug 23, 2019 3:44 pm
I found something strange when exporting from Blender.
The exporter sets (for a scaled object) the following line:
Code: Select all
scene.objects.Mesh_Sphere_140699409946120000.appliedtransformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
".appliedtransformation " defines the the local to world transformation (i.e. it is used to inform LuxCore of the applied vertex transformations):
https://github.com/LuxCoreRender/LuxCor ... s.cpp#L108
This transformation is used for some specific task like applying a procedural textures to several instances in local space (so it looks the same in all of them).
As you have noticed the the vertices are not expressed in local reference frame but already transformed in world reference frame for performance reasons (i.e to save a vector matrix multiplication). Because of this, BlendLuxCore needs to inform LuxCore of the transformations it has applied to the vertices.
lyinch wrote: Fri Aug 23, 2019 3:44 pm
I'm also a bit confused about the relation between objects and meshes.
The idea is that an object is only a binding of a mesh name/material name/etc. with a object name.
A shape/mesh is a set a triangle mesh or a transformation of something (like hairs/fur file, .ply file, etc.) into triangle mesh. The end result is always just a set of triangles (any transformation is done at the reprocessing time).
A shape/mesh doesn't exist in the rendered image until when it is used in an object.
Re: Bug in Blender exportation
Posted: Fri Aug 23, 2019 5:54 pm
by lyinch
Dade wrote: Fri Aug 23, 2019 4:18 pm
".appliedtransformation " defines the the local to world transformation (i.e. it is used to inform LuxCore of the applied vertex transformations):
https://github.com/LuxCoreRender/LuxCor ... s.cpp#L108
You're right, I found the same code here
https://github.com/LuxCoreRender/LuxCor ... ct.cpp#L75. It looks like this is missing in the Wiki for SDL v2.2 .
Dade wrote: Fri Aug 23, 2019 4:18 pm
As you have noticed the the vertices are not expressed in local reference frame but already transformed in world reference frame for performance reasons (i.e to save a vector matrix multiplication). Because of this, BlendLuxCore needs to inform LuxCore of the transformations it has applied to the vertices.
This makes sense. I guess that it's also better for the BVH to have the transformed objects such that we can build a correct tree rather than transform the ray/object on the fly when testing for intersections. Albeit, we could just do this computation once when loading all the objects at the beginning and store the transformed objects in memory.
Thank you for the explanations!