Perceptual Color Blending

calendar_today

04.04.2025

label

Texturing

mouse

Houdini 20.5

Description

Blending linear RGB colors (left column) using Oklab color space (right column) to improve perceptual uniformity as well as hue and lightness prediction.

1 Code

C
        function vector oklab(vector clr_A, clr_B; float bias){
    
    matrix3 kCONEtoLMS = set(                
         0.4121656120,  0.2118591070,  0.0883097947,
         0.5362752080,  0.6807189584,  0.2818474174,
         0.0514575653,  0.1074065790,  0.6302613616);
         
    matrix3 kLMStoCONE = set(
         4.0767245293, -1.2681437731, -0.0041119885,
        -3.3072168827,  2.6093323231, -0.7034763098,
         0.2307590544, -0.3411344290,  1.7068625689);
    
    vector lms_A = pow(kCONEtoLMS * clr_A, set(1.0 / 3.0));
    vector lms_B = pow(kCONEtoLMS * clr_B, set(1.0 / 3.0));
    
    vector lms = lerp(lms_A, lms_B, bias);
    lms *= 1.0 + 0.2 * bias * (1.0 - bias); // optional
    
    vector cone = kLMStoCONE * (lms * lms * lms);
    return cone;
}

vector clr_0 = chv('color_0');
vector clr_1 = chv('color_1');

vector uv = vertex(0, 'uv', i@vtxnum);

v@Cd = oklab(clr_0, clr_1, uv[1]);
    

2 Source

download

Downloads

link

Related articles

favorite

293

label

Texturing

Accumulating the amount of daylight

favorite

311

label

Texturing

Blending Object Colors into a Texture Map

favorite

373

label

Texturing

Camera Projection to a Curved Screen

favorite

307

label

Texturing

Camera visibility texture

favorite

307

label

Texturing

Mapping caustics from 3D meshes

favorite

286

label

Texturing

Circular Color Gradients in VOPs