How to use vertex colors?

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
Cleo
Posts: 3
Joined: Fri Jun 07, 2019 6:31 pm

How to use vertex colors?

Post by Cleo »

We had an event at work where we could work on anything for a day and my team tried to integrate luxrender into our company's 3D view. We only wanted one mesh (TIN), send camera and light (sun) direction. That main part went somewhat ok though it took us a very long time to figure things out. One part we absolutely could not figure out was how to use vertex colors. All our attempts failed and we could find no sample C++ code that did this. I tried to follow the source itself, but we were on a time limit. I was using matte material. I tried metal and some others, but nothing worked. Again, looked at the source code (and sample scenes) for properties to get vertex colors working to no avail. We tried both 2.1 and the most recent 2.2 beta.

I have a few questions.

1. How do you get vertex colors in DefineMesh() to work? Are they supposed to be diffuse colors?
2. Is there a list of all the properties documented somewhere? Wish the docs were a little clearer that there are almost no set methods. Those are all handled by properties.
3. What color space are the colors to DefineMesh()? I'm assuming RGB, but I saw a lot of XYZ or Spectrum data types that seemed to use the colors array.
4. Since each component of colors is float, what is the range? 0 to 1? 0 to 100? 0 to 255? Docs don't say.

Any help would be greatly appreciated.

BTW, the Windows SDK is missing the luxcore headers and library. Being new to luxcorerender, it took us a little while to realize that sdk could not be used.

Aside from the SDK and the colors issue, I was rather impressed with the library. I really like the Save() and Export() functionality for example.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: How to use vertex colors?

Post by Dade »

Cleo wrote: Fri Jun 07, 2019 7:00 pm We had an event at work where we could work on anything for a day and my team tried to integrate luxrender into our company's 3D view. We only wanted one mesh (TIN), send camera and light (sun) direction. That main part went somewhat ok though it took us a very long time to figure things out. One part we absolutely could not figure out was how to use vertex colors. All our attempts failed and we could find no sample C++ code that did this. I tried to follow the source itself, but we were on a time limit. I was using matte material. I tried metal and some others, but nothing worked.
Unfortunately, we don't have the resources to write a good developer documentation (also because, up to now, there hasn't been a lot of requests). However, my suggestion is to just ask in this forum if you have a problem, you are likely to get an answer in a very short time.
Cleo wrote: Fri Jun 07, 2019 7:00 pm Again, looked at the source code (and sample scenes) for properties to get vertex colors working to no avail. We tried both 2.1 and the most recent 2.2 beta.

I have a few questions.

1. How do you get vertex colors in DefineMesh() to work? Are they supposed to be diffuse colors?
Yes, vertex colors can be a bit confusing at first but it a quite powerful tool.

You define a color for each vertex in DefineMesh() (it is just an additional array of RGB floats). However it is not used by default, you have to use the "hitpointcolor" (https://wiki.luxcorerender.org/LuxCore_ ... pointcolor) texture to extract the information and use the result in a material.

You usually define a white matte material like:

Code: Select all

scene.materials.whitematte.type = matte
scene.materials.whitematte.kd = 0.7 0.7 0.7
If you want to use the vertex color information:

Code: Select all

scene.textures.vertexcolor.type = hitpointcolor
scene.materials.whitematte.type = matte
scene.materials.whitematte.kd = vertexcolor
It is everything you need in order to use vertex colors instead of the "0.7 0.7 0.7" constant texture.
2. Is there a list of all the properties documented somewhere? Wish the docs were a little clearer that there are almost no set methods. Those are all handled by properties.
Here: https://wiki.luxcorerender.org/LuxCore_ ... nce_Manual
3. What color space are the colors to DefineMesh()? I'm assuming RGB, but I saw a lot of XYZ or Spectrum data types that seemed to use the colors array.
RGB, you pass to DefineMesh() and array of "<vertex count> * 3" floats with an RGB value for each vertex.
4. Since each component of colors is float, what is the range? 0 to 1? 0 to 100? 0 to 255? Docs don't say.
Always [0.0, 1.0].
BTW, the Windows SDK is missing the luxcore headers and library. Being new to luxcorerender, it took us a little while to realize that sdk could not be used.
The problem should have been already fixed (but there hasn't been a new official release of the SDK since last stable release).
Support LuxCoreRender project with salts and bounties
Cleo
Posts: 3
Joined: Fri Jun 07, 2019 6:31 pm

Re: How to use vertex colors?

Post by Cleo »

WOW! Thank you so much! We looked at the kd property repeatedly. We even searched the source code for hitpointcolor (based on another forum post) and found nothing. I must have entered a typo or something. We were so close. We had tried using uv's on a 1D texture (though still technically 2D) and it seemed to work, but we ran out of time. Now, we'll at least be able to finish our proof of concept and see a color output.

Thanks again!
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: How to use vertex colors?

Post by Dade »

Cleo wrote: Sat Jun 08, 2019 4:44 am WOW! Thank you so much! We looked at the kd property repeatedly. We even searched the source code for hitpointcolor (based on another forum post) and found nothing. I must have entered a typo or something. We were so close. We had tried using uv's on a 1D texture (though still technically 2D) and it seemed to work, but we ran out of time. Now, we'll at least be able to finish our proof of concept and see a color output.
It is a bit cryptic as idea but it can be quite powerful: you can associate RGB and A information to each vertex and than elaborate them as you like with textures and finally use them inside any texture-enabled material parameter.
The idea was originally developed for hairs/furs (Alpha is used for a progressive transparency from the root to the tip and RGB is used for some nice fur pattern).
Support LuxCoreRender project with salts and bounties
Cleo
Posts: 3
Joined: Fri Jun 07, 2019 6:31 pm

Re: How to use vertex colors?

Post by Cleo »

I haven't looked at hair or fur yet, but you can use vertex color with "mix" textures and mix them with other textures to use diffuse colors with other effects, correct? Oh, you can use it as parameters in other textures too? Interesting idea.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: How to use vertex colors?

Post by B.Y.O.B. »

Cleo wrote: Sun Jun 09, 2019 8:41 pm Oh, you can use it as parameters in other textures too?
Yes, it's basically four floats per vertex (RGBA) that you can fill with any data you'd like, and you can drive any texturable material/texture parameter with it.
For example, you could paint the "wetness" of a surface in the red channel and use it to mix with a mirror material, and paint the "dirtiness" into the green channel and use that to mix with a dirt material of some kind - a lot of possibilities.
Post Reply