Combining LUTs and shaders may result in broken rendering
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
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
Working
With image-lut + upscaled (lanczos)
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.
Do you have similar problem with older libplacebo releases?
Do you have similar problem with older libplacebo releases?
How old?
I just reproduced with 7.349.0 using old Arch packages (grabbed with agetpkg):
x265-4.0-1-x86_64.pkg.tar.zst
ffmpeg-2:7.1.1-2-x86_64.pkg.tar.zst
libplacebo-7.349.0-7-x86_64.pkg.tar.zst
mpv-1:0.40.0-2-x86_64.pkg.tar.zst
How old?
7.349.0 is ok, I though it might be regression from more recent changes.