Bug in Blender exportation

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
lyinch
Posts: 3
Joined: Fri Aug 23, 2019 10:47 am

Bug in Blender exportation

Post 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.
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: Bug in Blender exportation

Post 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
Support LuxCoreRender project with salts and bounties
lyinch
Posts: 3
Joined: Fri Aug 23, 2019 10:47 am

Re: Bug in Blender exportation

Post by lyinch »

appliedtransformation is defined for

Code: Select all

scene.shapes<> 
and not for

Code: Select all

scene.objects<>
Which is what blender exported in my case
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Bug in Blender exportation

Post 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.
Support LuxCoreRender project with salts and bounties
lyinch
Posts: 3
Joined: Fri Aug 23, 2019 10:47 am

Re: Bug in Blender exportation

Post 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!
Post Reply