Page 1 of 2

Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Nov 19, 2019 11:16 am
by Dade
I have added the support for multiple mesh vertex UVs, Colors and Alphas.

LC_MESH_MAX_DATA_COUNT

The max. number of UVs, Colors and Alphas sets associated to mesh vertices is 6. It is a parameter (LC_MESH_MAX_DATA_COUNT) defined at LuxCore compilation time.

PLY file format

PLY file format doesn't natively support multiple UVs, Colors and Alphas so I had to extend the file format. Usually UVs are defined as "s" and "t" vertex channels, I added the support for "s1/"t1", "s2"/t2", etc. up to LC_MESH_MAX_DATA_COUNT. "red1"/"green1"/blue1", "red2"/"green2"/blue2", etc. for colors and "alpha1", "alpha2", etc. for alphas.

uvmapping2d and uvmapping3d

Now texture mapping uvmapping2d and uvmapping3d accept an additional parameter (".uvindex") where you can select the data set to use:

Code: Select all

scene.textures.tex1.type = imagemap
scene.textures.tex1.file = map.png
scene.textures.tex1.gamma = 2.2
scene.textures.tex1.mapping.type= uvmapping2d
scene.textures.tex1.mapping.uvindex = 1
scene.textures.tex1.mapping.uvscale = 2 2
hitpointcolor, hitpointalpha and hitpointgrey

Now textures hitpointcolor, hitpointalpha and hitpointgrey accept an additional parameter (".dataindex") where you can select the data set to use.

Implicit usage

UVs coordinates are implicitly used in many other contexts. For instance, Glossy material anisotropic direction, Cloth material direction, Pointiness, etc. At the moment, they are all still using the first UV data set (i.e. index 0). Eventually, the support for an explicit selection of the UV data set to use can be easily added.

Scene::DefineMeshExt()

Scene::DefineMeshExt() is the new method used in LuxCore API to define meshes with multiple vertex data sets.

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Nov 19, 2019 12:43 pm
by Sharlybg
That is a nice one ! thanks you and well done.

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Nov 19, 2019 3:46 pm
by marcatore
Very very good!!

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Nov 19, 2019 7:02 pm
by Racleborg
Great news. Thank you :)

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Wed Nov 20, 2019 7:56 am
by marcatore
Dade, just for my knowledge.
Why you must use PLY as export format?

I know that you 're not a 3dsmax developer, but how they can manage "infinite" ( I think that 255 is the max UV ID number available) UV IDs?
If you will be able to avoid export from Blender, you should have the same opportunity?

thank in advance.

In any case, it's already a great thing to have more than 1 ID.
For BYOB, I think that in the BlenderAddon, we should have or a constrained setting with the max number (6) or a tips near the ID number, avoiding to put a number outside the working ones.

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Wed Nov 20, 2019 8:28 am
by Dade
marcatore wrote: Wed Nov 20, 2019 7:56 am Why you must use PLY as export format?
It was the format used by LuxRender, it is also not particularly important because it is used only to export/import scene in text format (there is also a binary format).
BlendLuxCore directly exchanges the meshes with LuxCore on RAM (it doesn't write any file).

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Wed Nov 20, 2019 8:30 am
by Egert_Kanep
So with this addition we could possibly fake up to 6 UDIMS :D. If I got it right. This is an amazing addition

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Mon Dec 30, 2019 10:25 pm
by B.Y.O.B.
Dade wrote: Tue Nov 19, 2019 11:16 am LC_MESH_MAX_DATA_COUNT

The max. number of UVs, Colors and Alphas sets associated to mesh vertices is 6. It is a parameter (LC_MESH_MAX_DATA_COUNT) defined at LuxCore compilation time.
Is there a reason why this can't be dynamic?
I already had a report about a user hitting this limit.

edit: It looks like Blender has a limit of 8, so it would be great if we could use that as well.

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Dec 31, 2019 1:45 am
by Dade
B.Y.O.B. wrote: Mon Dec 30, 2019 10:25 pm Is there a reason why this can't be dynamic?
GPUs and dynamic memory allocation don't go well together.
B.Y.O.B. wrote: Mon Dec 30, 2019 10:25 pm I already had a report about a user hitting this limit.

edit: It looks like Blender has a limit of 8, so it would be great if we could use that as well.
It has a cost (in term of memory and performance) but I guess it is small between 6 and 8 so I will switch to 8.

Re: Multiple mesh vertex UVs, Colors and Alphas support

Posted: Tue Dec 31, 2019 11:39 am
by Dade
Dade wrote: Tue Dec 31, 2019 1:45 am It has a cost (in term of memory and performance) but I guess it is small between 6 and 8 so I will switch to 8.
Done.