plotoptix icon indicating copy to clipboard operation
plotoptix copied to clipboard

Color the faces directly

Open robinenrico opened this issue 4 years ago • 8 comments

Thanks again for this really fast ray tracing package.

I was wondering if there is a way to color the faces directly instead of coloring via the vertices. In other words, we can update the color of the mesh by running: rt.update_mesh(c=np.array(n, 3))

However, this requires an array of colors for the vertices, is there a similar approach where c is a color for each face id?

robinenrico avatar Feb 08 '21 19:02 robinenrico

Hi,

If you need only a flat shading then you can use the face index buffer and display it with a color palette, like here.

If you need one of the shaded materials, then I would need to add shaders with a slightly modified logic, that takes color from the face index and applies it instead of interpolated colors from vertex indices.

Let me know what is your use case.

robertsulej avatar Feb 08 '21 20:02 robertsulej

Thanks for your fast reply! I indeed looked into that particular example.

If I'm correct, this will create a 2D image with a color palette based on the face ids. However, I'm looking into coloring the mesh. This will make sure that the mesh is colored during the 3D rendering.

robinenrico avatar Feb 09 '21 18:02 robinenrico

OK. I'll prepare the next release soon. Will try to include there also the modified shading of meshes. Stay tuned ;)

robertsulej avatar Feb 10 '21 09:02 robertsulej

Thanks a lot Robert, that would really help! Without trying to rush you, do you have any idea on when you plan the next release?

robinenrico avatar Feb 10 '21 17:02 robinenrico

1-2 weeks, I think. :)

robertsulej avatar Feb 10 '21 17:02 robertsulej

I have to make a minor release tomorrow, but did not manage to include new shaders. Sorry for delay! I'll push updates for you in the next release, which should be again in 1~2 weeks.

robertsulej avatar Mar 07 '21 21:03 robertsulej

Hi Rober, did you already find the time to look into the new shaders?

robinenrico avatar May 14 '21 12:05 robinenrico

I was working on that code for a while - changes in the shaders and in the Python API are minimal, but... there is a problem in between. Color buffer size now follows the number of the geometry primitives. For meshes, wireframes and curves it is the number of vertices/nodes. A mesh with some fixed number of vertices can have any number of faces - this does not fit the design of the mesh geometry code. I don't think repeating the whole structure with only differently managed color buffer is the best option, so I still need to figure out how to implement this request.

Sorry, it is a bit more than I thought at the beginning!

robertsulej avatar Jun 25 '21 17:06 robertsulej