# Flat shading in Makie

**URL:** <https://discourse.julialang.org/t/flat-shading-in-makie/15216>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [September 20, 2018, 6:58am UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216 "2018-09-20T06:58:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krcools](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krcools/32/10212_2.png) [@krcools](https://discourse.julialang.org/u/krcools)\
**Post date:** [September 20, 2018, 6:58am UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216/1 "2018-09-20T06:58:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 20, 2018, 9:32am UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216/2 "2018-09-20T09:32:30Z")

</div>

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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/4/94bb7e25ebdf5456aa6a85b68378a5230cffe8b0.jpeg)  
is currently not implemented, but shouldn’t be too hard to add… Most difficult question would be how to integrate it nicely 😉 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.

---

<div class="post-metadata">

**Author:** ![krcools](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krcools/32/10212_2.png) [@krcools](https://discourse.julialang.org/u/krcools)\
**Post date:** [September 20, 2018, 9:55am UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216/3 "2018-09-20T09:55:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 20, 2018, 10:09am UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216/4 "2018-09-20T10:09:17Z")

</div>

To implement it natively in OpenGL you’ll need to do something like what I do here:  
[https://github.com/JuliaPlots/Makie.jl/blob/master/src/glbackend/drawing\_primitives.jl#L333](https://github.com/JuliaPlots/Makie.jl/blob/master/src/glbackend/drawing_primitives.jl#L333)  
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 😉  
Let me know if you have any questions

---

<div class="post-metadata">

**Author:** ![3point1415](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/3point1415/32/219528_2.png) [@3point1415](https://discourse.julialang.org/u/3point1415)\
**Post date:** [November 24, 2025, 11:20pm UTC](https://discourse.julialang.org/t/flat-shading-in-makie/15216/5 "2025-11-24T23:20:04Z")

</div>

Can you share the recipe that constructs the mentioned GLNormalMesh or the manual workaround and provide an example of its usage?
