How to make 1D lut in C ++ for GLSL

I am starting to understand how to implement a fragment shader to make 1D LUT, but I try my best to find any good resources that will tell you how to make 1D LUT in C ++ and then texture it.

So, for the simple example below 1D below:

enter image description here

Would I make an array with the following data?

int colorLUT[255] = {255,
                     254,
                     253,
                     ...,
                     ...,
                     ...,
                     3,
                     2,
                     1,
                     0};

or unsigned charI guess I will texture it.

If so, how to create a LUT, then how would I convert it to a texture? Should i use glTexImage1D? Or is there a better way to do this? I really lose here, any advice would be helpful

, , , LUT, GLSL , .

: , 1D LUT, , .

enter image description here

+4
1

, 1D- .

1D- glTexImage1D(). GL_R8 GL_UNSIGNED_BYTE glTexImage1D(), , 8 . : lutData / GLubyte lutSize LUT:

glTexImage1D(GL_TEXTURE_1D, 0, GL_R8, lutSize, 0, GL_RED, GL_UNSIGNED_BYTE, lutData);

, 8 , , GL_R16 GL_R32F.

, , . :

glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

sampler1D . , 0.0 1.0, [0.0, 1.0], . , , [0.0, 1.0].

, , , . LUT , 1D- - .

OpenGL, 1D-, OpenGL ES, 2D- , 1.

, , , .

+3

Source: https://habr.com/ru/post/1544265/


All Articles