Soundbomber's picture

Blending Outlines

Does anyone know of a blending combination that would blend (or antialias) a line with its background but not with other objects in the scene?
I have a number of outlined polygons which, depending on the viewpoint, could all appear aligned behind each other. When this is the case the outlines (when using conventional blending) appear darker than they would if they were not aligned, presumably because each line is being blended with the next.
Anyone any pointers?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

Draw the lines first?

Soundbomber's picture

Doesnt work and just screws up my hidden detail

objarni's picture

Could you show screenshots of problems?

Soundbomber's picture

If you compare the top left view with say, the bottom left, you can see that the outlines of the bolt shapes are rendered in a shade close to black for the top left (plan view where all the bolts are lined up behind each other), compared to the bottom left where all the bolt outlines are the correct shade of gray.

AttachmentSize
Views.JPG34.57 KB
objarni's picture

[Could you post in .PNG instead of .JPG? The image is blurred since JPG is a lossy format. PNG is not.]

I would assume full-screen antialising is the way to go in this scenario. I think fiddling with blending-per-primitive will get you in a big complex mess :)

the Fiddler's picture

Looks like you need Order Independent Transparency. This is a tough problem to solve.

Nvidia has a paper that may be useful. Somewhat old, but it should apply to modern hardware, too: http://developer.nvidia.com/object/Interactive_Order_Transparency.html

Soundbomber's picture

I have just realised that I disabled writing to the depth buffer for the wire frame only (to get rid of some undesirable visual artefacts). I re-enabled depth buffer writing and the image improves somewhat.

AttachmentSize
Views.PNG126.75 KB
objarni's picture

Cool.

[Strange; the PNG-image looks scrambled too.]

Soundbomber's picture

Thanks for your replies, much appreciated.
My aim in this is to achieve a 3D simple model that is as visually pleasing as possible, with a set of simple(ish) geometric objects that have an edges (and possibly hidden detail). I thought this would be relatively easy to achieve, but it turns out that outlining isn't that easy to do with any great precision. I have tried various methods including stencilling, playing around with the depth buffer etc, but what you gain with one method in terms of, say, graphic accuracy, you seem to lose another aspect like, say z ordering. I like a challenge :), but maybe the whole outlining issue should be addressed by the OpenGL team?! Seems like it should be a bit easier somehow.
Anyway, weekend now (mmmmmmmmm beer!)

the Fiddler's picture

I read somewhere that DX11 hardware may support order-independent-transparency out of the box, like the awesome Kyro 2 (Geforce 2 era, also found in the Dreamcast).

Other possibilities:

Have you tried implementing outlining in a shader? True, you trade accuracy for simplicity, but you can get quite pleasing results with relatively little work.

The final solution is to disable blending completely and render regular aliased lines. You can then enable FSAA which doesn't suffer from the drawbacks of primitive AA. This is the method used by Blender3D with pretty nice results.

But as you said, weekend now :)