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

Thread: Writing the Blend-Color in the fragment shader

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    Writing the Blend-Color in the fragment shader

    As suggested, i re-post this thread in this forum.



    OpenGL does have an extra blend-color, which can be used in the blend-function with GL_CONSTANT_COLOR (especially GL_CONSTANT_ALPHA). What i like about this is, that i can thus use my alpha-channel for other data, and still get blending with some blend-factor. I don't waste the alpha-channel to write a value, that i will never ever use again.

    The problem however is, that the color is indeed fixed. When i use the alpha-channel, i can modulate the blend-factor with textures etc., but when using the constant blend color, it is all the same over the entire rendered object.


    Since we seem not to get the blend-shader any time soon, i would at least like to see this addition: Allow to write the blend-color in the fragment shader. It would actually only be a temporary factor for this particular fragment and will be discarded afterwards. If the FS does not write the value, use the value, that was set in the application.

    Of course one would need to be able to write different values for each render-target (since the blend-function can be different for each RT on modern hardware).

    This would allow to do proper blending with different factors per fragment, and use the alpha-channel for something completely different.


    Jan.

  2. #2
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    934

    Re: Writing the Blend-Color in the fragment shader

    Sound like a great idea which could even same quite come memory band wise!

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Writing the Blend-Color in the fragment shader

    I'd like to see something similar to DX11's unordered resource views, which expose something similar in the form of generic R/W texture and buffer access from within fragment (& compute) shaders.

    What could be cooler?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2004
    Location
    Czech Republic, EU
    Posts
    190

    Re: Writing the Blend-Color in the fragment shader

    DX10 has something similar. It's called Dual Source Color Blending and allows to output two RGBA values from a pixel shader and use them in the blend-function. There is a limitation that no more than one rendertarget can be bound.
    (usually just hobbyist) OpenGL driver developer

  5. #5
    Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    469

    Re: Writing the Blend-Color in the fragment shader

    AFAIK dual source color blending got dropped in DX 10.1 or DX 11

Posting Permissions

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