RE: New version of mesh branch.

```Hi all,

> -----Original Message-----
> From: Tavmjong Bah [mailto:tavmjong@free.fr]
> Sent: Tuesday, 7 February 2012 7:12 AM
> To: Rik Cabanier
> Cc: Israel Eisenberg; Cyril Concolato; www-svg
> Subject: Re: New version of mesh branch.
>
> @Israel: In your test at
> http://owl3d.com/tests/Gradient_Mesh/lerpHermite.html , try putting in the
> values [[0,0,0][127,127,127][255,255,255]]. The resulting gradient has visual
> artifacts. In this case you don't want the derivative to be zero at the border. You
> do want the derivative to be the same on both sides and these derivatives may
> be different for the different colors.
@Tav, I think you are right. The Microsoft paper [2] that I cited in the wiki page [1] indicates that a cubic spline is a good match to what Illustrator is doing. What Israel proposes, i.e. a cubic Bezier spline, might be the case. But you want to add additional constraints. The Microsoft paper adds that the cubic interpolation be monotonic. You want to keep monotonicity in the color profile if the color values at consecutive patches corners are monotonic. You probably want the derivative to be zero when the values are not monotonic to avoid overshoot.

@Israel, your explanation is interesting and interestingly it matches a bit the Microsoft paper. A few points intrigue me. The monotonic cubic spline interpolation that the Microsoft paper refers to uses some spline energy minimization. I think your approach based on symmetry is more interesting. But it is unclear to me how it behaves in the general case.

Using a bicubic Bezier patch definition for the color interpolation, you have to find the color value for 16 control points. 4 are being given by the patch corner colors. How would you find the other ones? Note that Microsoft proposes to fit a monotonic cubic curve only on the edges, not inside the patch, therefore there are only 8 color values to find.

I understand that if a patch corner is a local minimum or maximum, in the mesh, for instance in the x direction, then the color of the adjacent control point on that x axis is set to be the same value as the corner. Similarly for the y and the diagonal axis. What happens, when a corner is not a maximum? How would you decide the value of the neighboring control points?

If a corner is not belonging to another patch, apparently setting its neighboring control points to fit a quadratic Bezier curve seems to do the job. Except for the diagonal, that is strange. But that doesn't work if that same corner is also a maximum or a minimum. What do you think?

Regards,
Cyril