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 9 of 9

Thread: Selective transparency (transmit some wavelengths but not others)

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Location
    Silicon Valley
    Posts
    234

    Selective transparency (transmit some wavelengths but not others)

    Anybody know of a way to make an object transmit a certain color but block out other colors (e.g. colored glass)? I believe to do this right, during a blend you would have to be able to multiply a framebuffer value by a 3-vector instead of by a single float. As far as I know, the current blending options in OpenGL only give you a single float to work with.

    I have heard talk of blend shaders, but those don't exist yet.

    The only way I can think to accomplish this is to copy a piece of the framebuffer into a texture and then use that texture in a shader when you render your transparent object. Anyone have any better ideas?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Belmont, CA
    Posts
    249

    Re: Selective transparency (transmit some wavelengths but not others)

    Does BlendFuncSeparateEXT help?

    http://oss.sgi.com/projects/ogl-samp...c_separate.txt

    -W

  3. #3
    Intern Newbie
    Join Date
    Mar 2005
    Posts
    38

    Re: Selective transparency (transmit some wavelengths but not others)

    i think even glBlendFunc is ok with the mode DST_COLOR and ONE_MINUS_DST_COLOR instead of the usual _ALPHA ones.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Location
    Silicon Valley
    Posts
    234

    Re: Selective transparency (transmit some wavelengths but not others)

    Thanks for the suggestions guys; your responses got me digging in the right places. Looks like GL_CONSTANT_COLOR and glBlendColor might be the solution. Looks like I also need a more up-to-date red book because I've never heard of either of those before today.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2004
    Posts
    15

    Re: Selective transparency (transmit some wavelengths but not others)

    You could accomplish the result you seek by using the accumulation buffer.

  6. #6
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    2,833

    Re: Selective transparency (transmit some wavelengths but not others)

    ...and kill your frame rate.
    Knackered

  7. #7
    Junior Member Newbie
    Join Date
    Apr 2004
    Posts
    15

    Re: Selective transparency (transmit some wavelengths but not others)

    The Radeon 9800 says it has a hardware accelerated accumulation buffer, although I've never tested its performance.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Jan 2004
    Location
    .dk
    Posts
    134

    Re: Selective transparency (transmit some wavelengths but not others)

    I sorta don't get it. How is what you want different from a regular blend? If you want to scale what is already in the framebuffer by a different value than the color of your glass, you could do a multipass-solution, and first render the color you wish to scale by, and then add the color of the glass. Then again, I probably just don't get it

  9. #9
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962

    Re: Selective transparency (transmit some wavelengths but not others)

    If the SRC_COLOR and DST_COLOR are insufficient for you then just draw the object three times with different alpha values and use glColorMask.

    Depending on your data you could get away with two passes if you use one pass with SRC_COLOR for source and ZERO for destination in the first pass then ZERO for destination factor and GL_ONE for the second pass if you premultiply component alphas by component color for the object's second pass rendering. It depends a lot of whether you can preprocess the source data.

    Neither solution is very difficult and both are doable with reasonable performance.

Posting Permissions

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