Replicating grease pencil's fill effect in threejs

Hello everyone, I’m trying to figure out if there is a way to replicate Blender’s grease pencil material fill effect in threejs (scroll down for an overview of the fill).

The grease pencil fill is a shader that “fills” the inside of a series of vertices defined by the grease pencil object. It always shows like a fill, even if the points are not coplanar.


Now, I know that is possible to triangulate with Earcut and (kind of) create a mesh from not coplanar vertices and achieve a similar result, but… it’s expensive and sometimes buggy if the vertices aren’t playing well together.

So, since I googled quite a bit and even tried inspecting Blender’s source code to figure out if I could find the shader but came up empty ended: would this be possible with a shaderMaterial? And if yes, could someone point me in the right direction?

(I know I’m asking quite a bit since shaders are kind of their own black magic. I’m willing to put in the work but I need some pointers)