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: change register combiner's mux operator

  1. #1
    Junior Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    145

    change register combiner's mux operator

    Hi,

    having an RGBA texture, I want to render only the parts which are in an alpha range of [a,b]. Two pass algorithm is working (using glAlphaFunc) but I want to do it in a single pass.
    By using the register combiners' mux operations this could be done, but the mux selects A*B or C*D by comparing spare0's alpha to 0.5. So, my question is how to map the a and b so that they can be used in the mux operator, instead of 0.5?
    Or is there another one pass algorithm to do it?

    Thanks
    kon

    /edit adding/subtracting the difference of a,b and 0.5 to the texture's alpha values is possible but it takes a register combiner and I've got only two of them and these are needed for the two muxs!

    [This message has been edited by kon (edited 05-03-2002).]

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,594

    Re: change register combiner's mux operator

    well.. if alpha < min, set out.alpha to 0
    else set out.alpha to unsigned(max - alpha)

    result: 0 in out.alpha if alpha > max, 0 in out.alpha if alpha < min..
    check against 0 in the alphatest and you-re fine out..

    alpha<min == alpha-min<0 == alpha-min+.5<.5
    == alpha + (1-min) - .5 < .5

    you have to calculate this in the general combiner 0, and store in spare0.alpha (with some nice bias and such this goes well.. spare0.alpha = unsigned_identity(alpha)+unsigned_invert(min) biased by .5)

    calc (in the color combiner 0 for example unsigned(max - alpha) and store this in some spare0.rgb for example..

    then in the second combiner alpha you can do the mux against spare0.alpha, and return eighter 0 or spare0.rgb.

    glAlphaTest(GL_NOTEQUAL,0);

    everything nonzero alpha will be okay..

    hope that helped, cause i'm little confused myself.. long time no coding in the rc's anymore..
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  3. #3
    Member Regular Contributor
    Join Date
    May 2000
    Posts
    420

    Re: change register combiner's mux operator

    I'm assuming you intend the a and b to be constants (not something pulled from a texture or anything). If so, just set the alpha test to only accept pixels with an alpha value >= a. Then all you need to do is configure the register combiners to output an alpha of 0 for pixels that have an alpha value > b, or the actual alpha value otherwise. You can do this as follows:

    combiner 1: calculate b - alpha + .5 and output to spare0.alpha

    combiner 2: make A*B = alpha, make C*D = zero, and the mux will select the correct one for you. Output the result as the spare0.alpha

    final combiner: select spare0.alpha as your output alpha

    Hopefully that is enough description. If you need actual code let me know and I can probably try to put it together.
    Ron Frazier

  4. #4
    Member Regular Contributor
    Join Date
    May 2000
    Posts
    420

    Re: change register combiner's mux operator

    Originally posted by davepermen:
    hope that helped, cause i'm little confused myself
    You're not the only one confused by that
    Ron Frazier

  5. #5
    Junior Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    145

    Re: change register combiner's mux operator

    Ah, thanks I'll give it try this weekend! I'm not that much confused anymore!

    kon

Posting Permissions

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