Page MenuHome

Vertex color interpolation is incorrect
Closed, DuplicatePublic

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71

Blender Version
Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: rB84da05a8b806
Worked: 2.79, in vertex paint mode and blender internal render, but not in cycles render or cycles material preview

Short description of error
Vertex colours are interpolated incorrectly, they seem to be interpolated as sRGB rather than linear. This goes for Eevee, Cycles, viewport render, and grease pencil vertex colours.
Note that this is NOT vertices having the wrong colours! This is the colours in-between the vertices being wrong

Expected results:
(2.79 vertex paint mode)


(2.79 blender internal material preview)

(Interpolation between two colours using a gradient texture, correcting both colour's gamma before and after)

(Similar setup in Krita)

Actual (incorrect) results:
(vertex colours in all render views)


(same gradient and colours except mixed without correction)

There is no way around this, short of just painting the linear colours yourself and then gamma correcting them in-material. My only suggestion is something along the lines of vertex colours having their own colour space option dropdown in the same way images do, so vertex colours can be used for a non-visual purpose in addition to being correctly interpolated for visual purposes.

Event Timeline

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Needs Information from Developers.Jul 28 2021, 4:45 PM

Blender seems to do a simple vector interpolation representing RGB colors.

I'm not sure how it should be a color interpolation and what is that gamma correction.

Needs developer assistance.

Thank you for the report @Cici (constachymic).

Vertex colours are interpolated incorrectly, they seem to be interpolated as sRGB rather than linear.

You have this reversed, actually. But don’t fret, you are in good company.🤗

It is really easy to get these switched around when doing conversions — I do it all the time.

  • Tom Forsyth

I looked at this earlier but didn’t respond until now because I wanted to triple check to make sure I was giving you the correct information.

All gradient strips come from https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/ which is under the very permissive WTFPL license.


Figure 7 — For each gradient-pair, the top gradient is a linear interpolation between two colours in linear space, then the result converted to sRGB (gamma-correct). The bottom gradients are the results of interpolating between the exact same colours but directly in sRGB space (gamma-incorrect)

The bottom gradient is Yellow to Cyan, which is close to the one you are using here. The top of each gradient strip is interpolated in a linear space, and the bottom is in sRGB space.
It is the sRGB that goes to a more saturated green in the middle of the strip, while the linear interpolation stays lighter.


Figure 1 — Evenly-spaced greyscale bars in terms of emitted light intensity

In the linear interpolated Figure 1, the middle of the strip isn't what we call middle grey. It is a lighter color.


Figure 2 — Evenly-spaced greyscale bars in terms of perceptual light intensity

In order for the middle of the strip to be halfway in between black and white in our minds, an adjustment (here gamma 2.2) must be made.

Below is an image I made in Krita using the gradient tool, using Blender's OCIO config with the same settings as your file in Blender.

I saved it as a PNG with Force sRGB checked in the export settings. As you can see, it matches Blender's linear interpolation.

Now, you might prefer the look of the sRGB interpolation between certain colors, and that is a perfectly valid creative choice. You already have shown you know how to do this via gamma manipulation in the shader. Adding a dropdown for vertex colors is a feature request that would require a design and approval, which is out of scope of the bug tracker.

T91759 shed a light on this problem.
Eevee, Cycles, viewport render, grease pencil vertex colors consider Vertex Colors to be sRGB. However they are RGB.
The question to find out is: who is wrong?

The behavior in Blender 2.79 may be the deciding factor.