1D Color lookup in ofShader

Hello,

I am new to OpenGL GLSL and shader. I would like to perform a 1D color lookup to RGB webcam frames with ofShader, but I am not sure the followings:

  1. What is the dimension of grayscale lookup table, 1x256 or 256x1? I created the lookup table with this function:
  
  
ofTexture testApp::createLookupMask(float black, float white) {  
	int dim(256);  
	int min = black * 255;  
	int max = white * 255;  
  
	//Mat mat_lut(1, &dim, CV_8U);	// 256x1  
	Mat mat_lut(1, 256, CV_8U);	// 1x256  
	for(int i=0; i<256; i++) {  
		mat_lut.at<unsigned char>(i) = ofMap(i, min, max, 0, 255, true);  
	}  
  
	ofPixels pix_lut; toOf(mat_lut, pix_lut);  
	ofImage resultImg;   
	resultImg.setFromPixels(pix_lut);  
	resultImg.setImageType(OF_IMAGE_GRAYSCALE);  
  
	return resultImg.getTextureReference();  
}  
  

  1. What is the code inside .frag? I wrote these codes but have no effect at all:

lut.frag:

  
  
#extension GL_ARB_texture_rectangle : enable  
#extension GL_EXT_gpu_shader4 : enable  
uniform sampler2DRect baseTex;  
uniform sampler2D detailLutTex;   
vec2 texcoord0 = gl_TexCoord[0].st;  
   
void main(void)  
{  
	vec4 colorIn = texture2DRect(baseTex, texcoord0);  
	vec4 colorOut = texture2D(detailLutTex, texcoord0.st);  
	gl_FragColor = colorOut;  
}  
  

In update():

  
  
shader_lut.begin();  
ofEnableAlphaBlending();  
// Input params to shader  
shader_lut.setUniformTexture("baseTex", fbo_cam.getTextureReference(), 0);  
shader_lut.setUniformTexture("detailLutTex", lut_detail, 1);  // ofTexture lut_detail return by createLookupMask(0.f, 1.f);  
// Draw to FBO  
fbo_lut.begin();  
ofEnableAlphaBlending();  
ofSetColor(255,255,255);  
fbo_cam.draw(0, 0, CAM_W, CAM_H);  
ofDisableAlphaBlending();  
fbo_lut.end();  
shader_lut.end();  
  

One thing that jumps out at me: you need to bind those textures before you can use them in your shader, so:

  
lut_shader.begin();  
lut_detail.bind();  
// do drawing  
lut_detail.unbind();  
lut_shader.begin();  

Did you ever solve this problem? Was the binding the issue, or was there another problem?