To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 12909
12908  |  12910
Subject: 
Re: White noise around model with colored background
Newsgroups: 
lugnet.cad
Date: 
Mon, 20 Jun 2005 13:13:19 GMT
Viewed: 
1404 times
  
In lugnet.cad, Travis Cobbs wrote:

What we need it the ability to have the blending not occur in the color
channel at all when the background is fully tranparent.  As far as I
know, that's not possible.

Ok, I had a little time over the weekend to spend with the Red book,
and I think I may have it now.  Hopefully not too late to make it into
LDView version 3.0 RC 2.  ;^)

So to eliminate the halo, what we want to put around the image edges
of the destination buffer is the unblended source RGB colors and the
antialiasing coverage values in the alpha channel.  I think if you
turn on antialiasing, and don't enable blending, that's exactly what
you get.  However, we only want it on the outside edges (the halo).
Everywhere else we want to do the normal alpha blending to composite
the antialiased lines with whatever lies behind it.  This sounds like
a 2 pass operation to me.

Say you clear the destination image buffer with zeros in the alphas.
Then you draw all your opaque polygons with RGB1.  This puts a nice
mask into the alpha channel where the parts you want to draw with
the usual blended antialiasing are all ones, and the parts where the
halo will appear are still zeros.  Now I imagine you could have also
drawn the same mask into the stencil buffer.  Turn on the stencil
test and draw the unblended antialiased lines into the halo (where the
stencil is zero).  Then draw the blended parts of the antialiased lines
where the stencil is ones).

Actually I think you can do it without even involving the stencil
buffer.  Use the alpha test to do your stenciling.  To draw the
unblended antialiased lines into the halo bits do this.

  glBlendFunction(GL_ONE_MINUS_DEST_ALPHA, GL_ZERO);
  glAlphaFunc(GL_NOTEQUAL, 0);

The GL_ZERO ensures no blending with the dest buffer colors, and
the ONE_MINUS_DEST_ALPHA will give us the source RGBA (where A is
hopefully the coverage value) where the dest alpha was 0.  Where
the dest alpha was 1, you'll get all zeros, which won't pass the
alpha test of NOTEQUAL to 0.

Then draw the blended antialiased lines and let the depth buffer
block your drawing on the halo bits.

I'm sure there are other ways to do this.  Perhaps even the holy grail,
a single pass method.  But It hasn't come to me yet.

Enjoy,

Don



Message has 2 Replies:
  Re: White noise around model with colored background
 
(If you haven't read Don's message, go do that now. It's too long to quote here.) I have a few comments. The first is that it will only fully work if you set the line width to 2 or more. Otherwise, you'll have jaggies around the inside edges of the (...) (19 years ago, 20-Jun-05, to lugnet.cad)
  Re: White noise around model with colored background
 
(...) Well, it's certainly long past LDView 3.0 RC 2, but I did finally come back to this. After spending a few hours getting nice alpha data into the image file for transparent parts, I realized that the same set of steps would probably work for (...) (17 years ago, 10-Oct-07, to lugnet.cad, FTX)

Message is in Reply To:
  Re: White noise around model with colored background
 
(...) Unfortunately, that doesn't help. It still blends, which means that if (for instance) your edge is red, and you have a pixel that's 50% covered via antialiasing, then that pixel comes out dark red (50% red + 50% black = dark red) with 50% (...) (19 years ago, 9-Jun-05, to lugnet.cad)

18 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR