Jump to content
You must now use your email address to sign in [click for more info] ×

Gradient interpolation improvements


Recommended Posts

First, gradient stop interpolation is currently not being done in linear space. Here is how it currently looks like:

Gradient_Nonlinear.png.98058d1cf38155151314708b0fde21cf.png

How it should look like:

Gradient_Linear.png.8a6e2b8907cdffa8f77bf365893e0e59.png

This doesn't only affect the distribution of the two colors being interpolated but also what colors are produced in-between:

Gradient_Nonlinear2.png.67524348459c8494bce2412114c19a20.png

How it should look like:

Gradient_Linear2.png.d4ebe74534b7fe0f868179ee41f25bcb.png

I thought about posting this in the bug reporting section, but as it might have artistic utility to do it this way and for compatibility reasons, I guess it fits better in here as a suggestion for an option. In fact, there could simply be a gamma setting in the gradient popup, just like in the layer blending options, which could be set to 1.0 for a "correct" interpolation.

Secondly, as it is closely related, another suggestion I have is an interpolation easing option, which can produce much smoother gradients, among other things. For example, using cubic interpolation:

Gradient_LinearCubic.png.a64ce3fd03e60afa7cafdf18c3fd7f5a.png

Thanks, I hope you consider adding such options.

Link to comment
Share on other sites

Your post is interesting, and at the pure aesthetic level I do prefer what you say it should be rather than what it currently is.

I probably am getting in too deep, but I had a theory that the gradient would be different depending on which color model was being used for the original values. To test my theory, I set up a spreadsheet that could interpolate transitional values from two sets of original values. Then, I tried the same calculations on original values of the same colors when expressed in RGB, HSL, LAB, and CMYK.

Armed with those new values, I made a graphic test in Designer using the two specimens from your second test. For each case, I put the way it "should" be on top of the way it currently is. Next, I put triangles and lines keyed at the values derived from my spreadsheet. Here is a screenshot of my experiment:

1909383769_ScreenShot2021-06-18at11_55_32AM.thumb.png.dfc0b7c054784824038ac1dcc663e04b.png

What I found was that Affinity currently appears to interpolate in a linear fashion from RGB values (at least in this RGB document). I base that conclusion on the fact that the lines between the triangles keyed at my RGB values are indistinguishable against your specimen of the gradient as it currently is.

However, none of the other methods matched your "should be" specimen perfectly, but LAB came close. Do you mind sharing how you created that specimen?

(I originally guessed that HSL would give a more "natural" gradation than RGB, but I was quite wrong, and it seems obvious why I was wrong, now that I think about it. Still, it is an interesting effect, as it passes smoothly through the range of hues between two given colors.)

gradient interpolations.numbers

gradient interpolations.afdesign

Link to comment
Share on other sites

Interesting. I'm actually not aware of what the most "correct" color space for interpolation is. LAB does indeed seem to come quite close to linear sRGB in your example, and you can actually use that as your document color space and it will interpolate accordingly.

What I was referring to though is that, in sRGB documents, currently colors are interpolated without first applying the inverse sRGB transfer function on the stop colors, which is what I did (abusing one of my own programs) in the examples above.

sRGB colors are stored in a non-linear encoding to increase precision for lower (darker) values at the expense of higher ones, as 8 bit integers are not enough otherwise, but those values should never be used for processing if a correct result is expected. I assume the rationale for doing it regardless is to have consistent results in comparison to other software. A gamma setting (like the one for blending layers) could allow both results (approximately).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.