Results 1 to 2 of 2

Thread: 2d texture compositing, blending?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2005
    Posts
    5

    2d texture compositing, blending?

    I'm implementing a graphics buffering scheme for 2d composition. I'm limited to OpenGL 1.1. I've decided to use copyteximage2d as the main driving force of the application (also note that this is an application which has a swing/awt/java implemntation of this very same concept).

    All buffers/textures are RGBA and all drawing operations are under the the SRC_ALPHA, SRC_ALPHA_MINUS_ONE blend function.

    Basically, I clear the back buffer and do all of my drawing. I then copy the image into a texture of the appropriate size. I then clear the back buffer and begin to draw again, but copy this into a different texture.

    After all of this is done, I need to composite the two textures for a final image (think layers in photoshop or gimp). I'm having the problem that everything is too washed out because of the alpha values compounding and making the colors worse and worse.

    Clear example:

    I draw a green square on the first texture, 50% alpha. I draw a blue square on the second texture, 50%. I then composite the two textures. The blue looks more like 15% alpha than 50%.

    Also note that when I clear the back buffer, I clear to color (0.0, 0.0, 0.0, 0.0). I noticed that when I draw to the buffer, the colors gets blended with the back buffer color rather then written directly.

    Sorry if this doesn't make sense, the desired effect is very much like photoshop or the gimps layering functionality.

    Is this even possible with clever combinations of tex_env_mode, blendfunc and alpha test?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: 2d texture compositing, blending?

    Can you provide pictures of what you get along with what you expect ?

    Don't you forget to disable blending when drawing your initial textures A and B ?

    About performance, try copyTexSubImage2d, it can be faster (no texture allocation, just data update).

Similar Threads

  1. Compositing
    By sdrouin in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 12-10-2009, 01:46 AM
  2. Need help on 2d & 3d compositing!
    By yooyo in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 04-10-2009, 04:42 PM
  3. Depth to texture for compositing
    By abetts in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-27-2003, 02:10 AM
  4. Compositing 2 images
    By jf in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 08-15-2002, 11:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean