Skip to content

Combining LUTs and shaders may result in broken rendering #347

@MoSal

Description

@MoSal

I've seen weirdly broken rendering with a real-world LUT, but this should be an easy reproducer.

LUT

A simple LUT generated with:

#include <stdio.h>

int main() {
  int size = 13;
  float step = 1.0f / (size - 1);
  printf("LUT_3D_SIZE %d\n\n", size);
  for (int b_c=size-1; b_c >= 0; b_c--) {
    for (int g_c=size-1; g_c >= 0; g_c--) {
      for (int r_c=size-1; r_c >=0; r_c--) {
        printf("%g %g %g\n", (step*r_c - 0.1)*11.0/9.0, (step*g_c - 0.1)*11.0/9.0, (step*b_c - 0.1)*11.0/9.0);
      }
    }
  }
}

Shader

invert_custom.glsl.zip

Reproduction

mpv  --no-config --pause -image-lut file.lut -glsl-shader file.glsl av://lavfi:testsrc=size=1280x720
mpv  --no-config --pause -lut file.lut -glsl-shader file.glsl av://lavfi:testsrc=size=1280x720
mpv  --no-config --pause -target-lut file.lut -glsl-shader file.glsl av://lavfi:testsrc=size=1280x720
# or without mpv
ffplay -vf libplacebo=lut=file.lut:custom_shader_path=file.glsl -f lavfi testsrc

Results

Broken

With image-lut + unscaled

Image

Working

With image-lut + upscaled (lanczos)

Image


It's broken in all other cases: downscaling, lut, target-lut, or upscaling without a libplacebo shader (bilinear).

And even when the rendering is okay, non-window screenshots would still look broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions