View Full Version : add scaled texture color to another texture
dletozeun
04-16-2008, 04:09 AM
Hello,
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...
Thanks.
-NiCo-
04-16-2008, 04: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
glBlendColor(k,k,k,k);
glBlendFunc(GL_CONSTANT_COLOR,GL_ONE);
dletozeun
04-16-2008, 05: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...
dletozeun
04-16-2008, 06: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?
thanks
-NiCo-
04-16-2008, 06: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).
dletozeun
04-16-2008, 09: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:
GL_ARB_imaging OK [MISSING]
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.
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
GL_EXT_blend_color
dletozeun
04-17-2008, 02: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...
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.