Flat shading in Makie

Is it possible to have per face coloring/lighting for Makie.mesh (as opposed to per vertex)? This is more appropriate for the visualization of polyhedra or other shapes that have sharp corners and for the visualization of FEM/BEM solutions that use discontinuous elements for the approximation of the unknown field.

As it is now, face normals and solution amplitudes are forced to be continuous across all edges, even though they are not (in the above case).

It tried the shading and interpolate attributes, but without success.

shading = false gives you “super flat” shading, which is likely not what you want :frowning:
So real flat shading like this:

is currently not implemented, but shouldn’t be too hard to add… Most difficult question would be how to integrate it nicely :wink: You could already fake it by creating your own GLNormalMesh with duplicated vertices + normals, which wouldn’t be as performant as a native implementation but should already work fairly well.

Ah, yes… I’ll use that workaround for now. Many thanks for this!

I tried to descent into the package to find out where the actual rendering takes place, but convenience functions and @evals threw me of the track. Would implementing this require new code on the level of the now assimilated GLVisualize?

To implement it natively in OpenGL you’ll need to do something like what I do here:

That uses custom shaders to implement an existing makie type (3D contour) natively in the opengl backend.

But for a simple version, you could just write a recipe that constructs the mentioned GLNormalMesh :wink:
Let me know if you have any questions