[Public WebGL] Empty triangles when decrease opacity

Florian Bösch [email protected]
Fri Feb 17 09:03:02 PST 2012


On Fri, Feb 17, 2012 at 5:54 PM, Nicolas Rannou <[email protected]>wrote:

> If I decrease the opacity of my meshes in the color fragment, some
> triangles become transparent...
> Would somebody know what could cause such a behavior?
>
> The meshes look fine with an opacity of 1...
>

When alpha blending it is important that a fragment emitted further from
the observer is drawn before a fragment emitted closer to an observer. I.e.
all fragments that should be blended need to be drawn back to front. Your
mesh is drawn in a random order, which does not coincide with the
requirement to draw it back to front.

Solutions:
- One common solution to this problem is to sort the triangles back to
front before drawing them (this may be expensive if you need to upload a
lot of triangles every frame). This has a few degenerate cases (in case of
overlapping loops or intersecting triangles).
- Other solutions to the problem of unordered fragments are depth peeling
(expensive to do in WebGL because we have no multi-render targets)
- Linked lists of fragments (impossible to do in WebGL because we have no
compute shaders or the like)
- Using additive blending (cheap but not always desired)
- Faking order independent blending by blending additively, and dividing by
a counter (better than straight up additive, but of course not perfect)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20120217/573a0f40/attachment.html>


More information about the public_webgl mailing list