View Full Version : add scaled texture color to another texture

04-16-2008, 05:09 AM

I need your opinion about a very simple problem.

I would like to add a texture Ts which color is scaled by a factor K (K between 0 and 1) to another texture Td. the result is the texture T = K*Ts + Td, so I just wan't to scale Ts color not Td color.
My question is: Is it possible to do that with only 2 textures with blending or glsl shaders? I mean that I would like to read and write the same texture (T=Td) using FBO to render to the texture. I am not sure that it is a good thing to read and write a texture at the same time in a shader and in my opinion it is not possible to compute this with gl blending...


04-16-2008, 05:17 AM
You can attach Td to the FBO and render a full screen quad textured with Ts to it using blending. As the blend function use


04-16-2008, 06:53 AM
Thanks a lot Nico.

This is a simple solution, I will try to do this. I did not find the GL_CONSTANT_COLOR constant the first time, It varies following the specification versions...

04-16-2008, 07:03 AM
I have just seen that I need the GL_ARB_imaging extension and my graphic card (ATI mobility X1600) seems to not support this...

Is there another solution or can I use GL_CONSTANT_COLOR with the classic glColor* function?


04-16-2008, 07:04 AM
Well, you could also have used glBlendFunc(GL_ONE,GL_ONE)
set the texture environment to GL_MODULATE (default) and draw the Ts texture with glColor4f(k,k,k,k).

04-16-2008, 10:40 AM
Yes you are right but I think that I would have to draw Ts and Td at the same time using multitexturing in the Td texture ( R/W the same texture)

Nevertheless I tried to use glBlendColor function and it works...
In fact I did not see GL_ARB_imaging with glxinfo (on linux) but then with glewinfo, I have this:


I don't understand what it means but it seems to work correctly and I have seen that this extension is supported by many implementations...

thank you.

04-16-2008, 04:56 PM
I have just seen that I need the GL_ARB_imaging extension and my graphic card (ATI mobility X1600) seems to not support this...
it should do (even if its not in the extension string), as i just looked + X1600 supports opengl2.0

constant color blend came from the old extension

04-17-2008, 03:01 AM
X1600 supports opengl2.0

Yes you are right, this explains why this extension is not in the extension string.
In any case the explanation of glew with OK [MISSED] is very ambiguous...