Skip to content

Implement LUTs color grading using .cube files? #1436

Answered by ehsanbigzad
ehsanbigzad asked this question in Q&A
Discussion options

You must be logged in to vote

Here how I achieved using shaders by providing LUTs (512x512)px file as .png instead of .cube, maybe help someone.

Declarative implementation

const paint = Skia.Paint();

const source = Skia.RuntimeEffect.Make(`
  uniform shader image;
  uniform shader luts;

  half4 main(float2 xy) {
    vec4 color = image.eval(xy);

    int r = int(color.r * 255.0 / 4);
    int g = int(color.g * 255.0 / 4);
    int b = int(color.b * 255.0 / 4);
    
    float lutX = float(int(mod(float(b), 8.0)) * 64 + r);
    float lutY = float(int((b / 8) * 64 + g));
    
    vec4 lutsColor = luts.eval(float2(lutX, lutY));

    return lutsColor;
  }
`)!;

export default function Picture() {
  const luts = useImage(req…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@wcandillon
Comment options

@anhquan291
Comment options

Answer selected by ehsanbigzad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants