Hacker News new | ask | show | jobs
by vanderZwan 1913 days ago
Really cool!

So it looks like you're first applying Delauny triangulation to the color points, and then apply linear interpolation along the created triangles using Barycentric coordinates? Did I get that right? Pretty elegant solution (not to mention all the other little details that went into designing the interface).

edit: wait, if I'm placing a outside the existing shape it's projected to the closest line and linearly interpolates on it? Nice, this is really thought through!

The colors still looks a bit strange along the triangle edges sometimes, and glancing at the source code it seems like you're mixing in linear RGB[0] so it's not that. I guess that just means that I'm looking at a saddle point in the color space?

(this made me wonder how smoothing functions would work for triangle meshes (that aren't secretly quads split into two triangles), and a quick search suggests that could be quite a deep rabbit hole to fall into)

[0] https://github.com/grgrdvrt/poulette/blob/main/src/utils/col...

1 comments

Thank you!

This is indeed Delaunay triangulation, barycentric coordinates, linear RGB and projections on the edges for the points outside of the mesh. You got everything right!

Having a nice blending along the edges doesn't seem straightforward. I have a few options in mind but nothing obviously right (working with a voronoi diagram instead of a delaunay one, bezier interpolation)

Maybe a single pass of root-of-3 subdivision would already help? It would insert another "control point" at the middle of the existing triangles. Then you could linearly interpolate along the new refined triangles. That wouldn't really remove the saddle points (if my intuition is correct it would just divide them into smaller ones along the new triangles), but maybe they'll end up more smoothed out and therefore less jarring.

[0] https://www.graphics.rwth-aachen.de/media/papers/sqrt31.pdf