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

Thread: How does blending (color vs alpha) work for single-channel render target?

  1. #1
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61

    How does blending (color vs alpha) work for single-channel render target?

    I'm porting some code from a technical paper, and they use a render target with only one channel - it's a 16-bit float buffer. But then they set blending operations on it like this:
    glBlendFunci(1, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);





    How does blending work with regard to color and alpha if the target is only one components? With only one channel, does that mean that it defaults to only being an alpha channel?

    Thanks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,714
    How is the render target texture created? And is this core or compatibility OpenGL? That will give you your answer.

    To be more specific, typically a single-channel anything may be treated as if it were using the red channel. Legacy versions of the OpenGL specification do contain rules for conversion from the old GL_LUMINANCE and GL_LUMINANCE_ALPHA formats, whereas newer core GL versions require you to explicitly use e.g. GL_RED (i.e. GL_LUMINANCE and GL_LUMINANCE_ALPHA no longer exist). See e.g. page 128/table 3.15 of the OpenGL 1.5 specification: https://www.khronos.org/registry/Ope...l/glspec15.pdf, or for a core context check your glTexImage/glTexStorage call to determine which format is used.

  3. #3
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,924
    LUMINANCE formats are not color-renderable, so you can't render to them. Even in compatibility OpenGL.

  4. #4
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61
    Actually this is for Metal -- so maybe it is different from OpenGL? With Metal my fragment function does not return a full 4-component color but rather a single float value. And it seems like Metal interprets that as a color value, which means there would be no SRC_ALPHA for that blend function...?

Tags for this Thread

Posting Permissions

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