Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: ANY way to do proper fuzzy translucent overlapping lines in OpenGL?

  1. #11
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61
    Yes, that is what I was asking -- are you certain it's possible to fix the triangle mesh when the vertices can all pile up when seen from end-on? I'm not sure about that.

    I haven't had time to try the blending, been working on other stuff. I hope to try it this week, though I don't have my hopes up for it working. After all, as you draw fragments into the framebuffer, they are blending with the background color, so further fragments would be tainted by that. I'm thinking of the areas around the edges where the alpha is not a constant but falls off to 0...

  2. #12
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,156
    Quote Originally Posted by bsabiston View Post
    Yes, that is what I was asking -- are you certain it's possible to fix the triangle mesh when the vertices can all pile up when seen from end-on? I'm not sure about that.
    No, I was only talking about the case for avoiding overlap of adjacent triangles in the polyline mesh when laying them out on a 2D plane, not addressing how to avoid overlap when you treat that polyline as 3D and rotate it so as seen edge-on where geometry projects to the same pixels.

    I haven't had time to try the blending, been working on other stuff. I hope to try it this week, though I don't have my hopes up for it working. After all, as you draw fragments into the framebuffer, they are blending with the background color, so further fragments would be tainted by that. I'm thinking of the areas around the edges where the alpha is not a constant but falls off to 0...
    I understand your concern. However, I think you're missing a subtle detail about what I was suggesting that perhaps I wasn't clear about. First, we use max blending in the scratch buffer just to compute the per-pixel alpha values. Then we blend the line color onto the screen using those alpha values, ensuring that we never update a pixel more than once.

    There are a number of ways to do that. One is to just use a full-screen quad of the right color using those alpha values, but that has a lot of potential fill cost. Another is to just draw the polyline to the screen and use stencil test/set to ensure that no pixel is updated more than once.
    Last edited by Dark Photon; 10-16-2017 at 06:12 AM.

  3. #13
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61
    I finally got a chance to try this today -- been sidetracked on some other things -- and it works great! I draw the lines twice -- the first time sets the max alpha in the framebuffer's alpha channel. The second pass blends the Source RGB with the destAlpha, and it also stores 0 in the dest alpha to erase the buffer for the next pass. I haven't tried using a stencil buffer yet -- but I don't really need to, because when the alpha is set to zero by the second-pass write, any further writes to that pixel are multiplied by the zero alpha.
    https://imgur.com/PV0fIQ8

    The only problem is that there's a slight artifact at the joins where lines cross. For some reason it looks like the alpha is lighter than it should be at these creases. I don't see why it would do that. Do you know?

    https://imgur.com/wxQaFc3
    https://imgur.com/OrVMpkF

    That closeup is a picture of the alpha mask after the first write -- so the problem is happening there, before the second stage. I would think the 'max' would make it darker than it should be, if anything. But it looks lighter?

    Anyway thanks for the help, it is so much better than it was -- is actually usable now.

  4. #14
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,156
    Quote Originally Posted by bsabiston View Post
    The only problem is that there's a slight artifact at the joins where lines cross. For some reason it looks like the alpha is lighter than it should be at these creases. I don't see why it would do that. Do you know?
    It definitely looks like that. Not sure why. You may just want to trace it through and see what's going on for those overlap texels. Are you sure there's no testing/setting going on (e.g. depth, stencil, etc.) besides the alpha values with max blending? No MSAA rasterization and downsampling?

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
  •