Skip to main content
Added the texture creation and loading code
Source Link

I simply changedThe texture creation code

glGenTextures(1, &m_FluorShadersParams[fpsFused].m_LutTexture);  
glBindTexture(GL_TEXTURE_2D, m_FluorShadersParams[fpsFused].m_LutTexture);  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);  

glActiveTexture(FluorTextureIndexes[fpsFused]);  
glBindTexture(GL_TEXTURE_2D, m_FluorShadersParams[fpsFused].m_LutTexture);  

glActiveTexture(GL_TEXTURE0);  
glBindTexture(GL_TEXTURE_2D, 0);  

Filling the texture with data

glActiveTexture(a_FluorTextureIndexes[fpsFused]);  
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, pLUT);  
glActiveTexture(GL_TEXTURE0);  

Calling the shader

glUseProgram(m_progObj[fsFluorFused]);

glActiveTexture(FluorTextureIndexes[fpsFused]);
glBindTexture(GL_TEXTURE_2D, FluorTextureIndexesNum[fpsFused]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, inputTextures[eftIR]); // Fluor image

glBindFramebuffer(GL_FRAMEBUFFER,outputFBO.m_FBO[eftFused]);

uniformLoc = glGetUniformLocation(m_progObj[fsFluorFused], "FluorImage");
if (uniformLoc != -1)
{
  glUniform1i(uniformLoc, 1);
}
        
uniformLoc = glGetUniformLocation(m_progObj[fsFluorFused], "FluorColorLutRGBA");
if (uniformLoc != -1)
{
  glUniform1i(uniformLoc, FluorTextureIndexesNum[fpsFused]); 
}

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);
 glTexCoord2f(0,    fTextureRatioY);            
 glVertex2f(0,      fTextureRatioY);
 glTexCoord2f(fTextureRatioX,   fTextureRatioY);      
 glVertex2f(fTextureRatioX,     fTextureRatioY);
 glTexCoord2f(fTextureRatioX,   0);         
 glVertex2f(fTextureRatioX,     0);
 glTexCoord2f(0,        0);      
 glVertex2f(0,          0);
glEnd();
         
glUseProgram(0);
glActiveTexture(GL_TEXTURE0);

glBindFramebuffer(GL_FRAMEBUFFER,0);
glBindTexture(GL_TEXTURE_2D,0);

The strange thing is that if i change all the places in the c++ code back from Texture1D into Texture2D into Texture1D and updated the size ofsampler in the textureshader to be 256x11D everything works great.
Anyone has any idea where the issue can be?

I simply changed all the places in the c++ code from Texture1D into Texture2D and updated the size of the texture to be 256x1.
Anyone has any idea where the issue can be?

The texture creation code

glGenTextures(1, &m_FluorShadersParams[fpsFused].m_LutTexture);  
glBindTexture(GL_TEXTURE_2D, m_FluorShadersParams[fpsFused].m_LutTexture);  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);  

glActiveTexture(FluorTextureIndexes[fpsFused]);  
glBindTexture(GL_TEXTURE_2D, m_FluorShadersParams[fpsFused].m_LutTexture);  

glActiveTexture(GL_TEXTURE0);  
glBindTexture(GL_TEXTURE_2D, 0);  

Filling the texture with data

glActiveTexture(a_FluorTextureIndexes[fpsFused]);  
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, pLUT);  
glActiveTexture(GL_TEXTURE0);  

Calling the shader

glUseProgram(m_progObj[fsFluorFused]);

glActiveTexture(FluorTextureIndexes[fpsFused]);
glBindTexture(GL_TEXTURE_2D, FluorTextureIndexesNum[fpsFused]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, inputTextures[eftIR]); // Fluor image

glBindFramebuffer(GL_FRAMEBUFFER,outputFBO.m_FBO[eftFused]);

uniformLoc = glGetUniformLocation(m_progObj[fsFluorFused], "FluorImage");
if (uniformLoc != -1)
{
  glUniform1i(uniformLoc, 1);
}
        
uniformLoc = glGetUniformLocation(m_progObj[fsFluorFused], "FluorColorLutRGBA");
if (uniformLoc != -1)
{
  glUniform1i(uniformLoc, FluorTextureIndexesNum[fpsFused]); 
}

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);
 glTexCoord2f(0,    fTextureRatioY);            
 glVertex2f(0,      fTextureRatioY);
 glTexCoord2f(fTextureRatioX,   fTextureRatioY);      
 glVertex2f(fTextureRatioX,     fTextureRatioY);
 glTexCoord2f(fTextureRatioX,   0);         
 glVertex2f(fTextureRatioX,     0);
 glTexCoord2f(0,        0);      
 glVertex2f(0,          0);
glEnd();
         
glUseProgram(0);
glActiveTexture(GL_TEXTURE0);

glBindFramebuffer(GL_FRAMEBUFFER,0);
glBindTexture(GL_TEXTURE_2D,0);

The strange thing is that if i change all the places in the code back from Texture2D into Texture1D and the sampler in the shader to 1D everything works great.
Anyone has any idea where the issue can be?

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture.
Since i need to support computers that don't support the 1D texture in the shader i thought the easiest would be to convert the 1D texture to a 2D texture with the height==1.
After the conversion (1D -> 2D) when i run the program it seems that the LUT 2D texture is received gray in the shader. I render the exact same texture in another place (not using a shader) in the program and the texture looks fine (same as it did when i used a 1D texture).
The shader code:

uniform sampler2D FluorImage;
uniform sampler2D FluorColorLutRGBA;

void main(void)
{
vec3 FluorPix = texture2D(FluorImage, gl_TexCoord[0].st).rgb;
vec2 Coord = vec2(FluorPix.g, 0.0);
vec4 NewColorFluor = texture2D(FluorColorLutRGBA, Coord).rgba;
gl_FragColor.rgb = NewColorFluor.rgb;
}

uniform sampler2D FluorImage;  
uniform sampler2D FluorColorLutRGBA;  

void main(void)  
{  
  vec3 FluorPix = texture2D(FluorImage, gl_TexCoord[0].st).rgb;  
  vec2 Coord = vec2(FluorPix.g, 0.0);  
  vec4 NewColorFluor = texture2D(FluorColorLutRGBA, Coord).rgba;  
  gl_FragColor.rgb  = NewColorFluor.rgb;  
}  

I simply changed all the places in the c++ code from Texture1D into Texture2D and updated the size of the texture to be 256x1.
Anyone has any idea where the issue can be?

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture.
Since i need to support computers that don't support the 1D texture in the shader i thought the easiest would be to convert the 1D texture to a 2D texture with the height==1.
After the conversion (1D -> 2D) when i run the program it seems that the LUT 2D texture is received gray in the shader. I render the exact same texture in another place (not using a shader) in the program and the texture looks fine (same as it did when i used a 1D texture).
The shader code:

uniform sampler2D FluorImage;
uniform sampler2D FluorColorLutRGBA;

void main(void)
{
vec3 FluorPix = texture2D(FluorImage, gl_TexCoord[0].st).rgb;
vec2 Coord = vec2(FluorPix.g, 0.0);
vec4 NewColorFluor = texture2D(FluorColorLutRGBA, Coord).rgba;
gl_FragColor.rgb = NewColorFluor.rgb;
}

I simply changed all the places in the c++ code from Texture1D into Texture2D and updated the size of the texture to be 256x1.
Anyone has any idea where the issue can be?

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture.
Since i need to support computers that don't support the 1D texture in the shader i thought the easiest would be to convert the 1D texture to a 2D texture with the height==1.
After the conversion (1D -> 2D) when i run the program it seems that the LUT 2D texture is received gray in the shader. I render the exact same texture in another place (not using a shader) in the program and the texture looks fine (same as it did when i used a 1D texture).
The shader code:

uniform sampler2D FluorImage;  
uniform sampler2D FluorColorLutRGBA;  

void main(void)  
{  
  vec3 FluorPix = texture2D(FluorImage, gl_TexCoord[0].st).rgb;  
  vec2 Coord = vec2(FluorPix.g, 0.0);  
  vec4 NewColorFluor = texture2D(FluorColorLutRGBA, Coord).rgba;  
  gl_FragColor.rgb  = NewColorFluor.rgb;  
}  

I simply changed all the places in the c++ code from Texture1D into Texture2D and updated the size of the texture to be 256x1.
Anyone has any idea where the issue can be?

Source Link

2D RGBA texture is gray in GLSL shader

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture.
Since i need to support computers that don't support the 1D texture in the shader i thought the easiest would be to convert the 1D texture to a 2D texture with the height==1.
After the conversion (1D -> 2D) when i run the program it seems that the LUT 2D texture is received gray in the shader. I render the exact same texture in another place (not using a shader) in the program and the texture looks fine (same as it did when i used a 1D texture).
The shader code:

uniform sampler2D FluorImage;
uniform sampler2D FluorColorLutRGBA;

void main(void)
{
vec3 FluorPix = texture2D(FluorImage, gl_TexCoord[0].st).rgb;
vec2 Coord = vec2(FluorPix.g, 0.0);
vec4 NewColorFluor = texture2D(FluorColorLutRGBA, Coord).rgba;
gl_FragColor.rgb = NewColorFluor.rgb;
}

I simply changed all the places in the c++ code from Texture1D into Texture2D and updated the size of the texture to be 256x1.
Anyone has any idea where the issue can be?