Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: add scaled texture color to another texture

  1. #1
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    add scaled texture color to another texture

    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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: add scaled texture color to another texture

    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);

  3. #3
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: add scaled texture color to another texture

    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...

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: add scaled texture color to another texture

    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

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: add scaled texture color to another texture

    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).

  6. #6
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: add scaled texture color to another texture

    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.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: add scaled texture color to another texture

    Quote Originally Posted by dletozeun
    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

  8. #8
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: add scaled texture color to another texture

    Quote Originally Posted by zed
    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •