Heuristic42
Blog
Opengl
Meta
Rendering
1
comment
Nov 19 at 15:47
Matrices
Hello, I hope this message finds you doing well. I believe…
–
anonymous
created
Oct 20 at 20:30
Iterators: pointers vs cursors
You're already doing both of these by hand. This post emphaisze…
–
pknowles
comment
Oct 10 at 10:27
Matrices
[deleted]
–
anonymous
comment
Oct 4 at 19:12
Matrices
[deleted]
–
anonymous
comment
Sep 30 at 18:51
Matrices
[deleted]
–
anonymous
comment
Sep 23 at 16:15
Matrices
[deleted]
–
anonymous
comment
Sep 21 at 6:52
Contributing
I kind of predicted what was bound to happen when my favourite …
–
anonymous
comment
Sep 7 at 1:21
Route contention when running docker and a VPN
Thank you for this. Between this and the overwriting of iptabl…
–
anonymous
comment
Sep 6 at 17:57
Making a real EMF Reader
Sorry for the random quoted text comments. I am one of those p…
–
anonymous
comment
Sep 6 at 17:48
Making a real EMF Reader
["ove! Play a tone with a buzzer and has 5 LEDs to show the “EM…
–
anonymous
comment
Sep 6 at 17:47
Making a real EMF Reader
["easure direction Measure the magnetic fie"](#q107-644-685)
–
anonymous
comment
Aug 20 at 17:01
Matrices
[deleted]
–
anonymous
comment
Aug 11 at 22:32
Matrices
[deleted]
–
anonymous
edited
Jun 8 at 22:29
Rethinking writing files with memory mapping and C++
This post introduces the motivation behind the [decodless C++ o…
–
admin
created
Jun 8 at 22:16
Rethinking writing files with memory mapping and C++
This post introduces the motivation behind the [decodless C++ o…
–
pknowles
comment
Jun 5 at 13:36
Contributing
[deleted]
–
anonymous
comment
Apr 19 at 11:24
Matrices
[deleted]
–
anonymous
comment
Apr 13 at 0:25
Matrices
[deleted]
–
anonymous
comment
Apr 5 at 9:43
Matrices
[deleted]
–
anonymous
comment
Mar 27 at 17:19
Matrices
[deleted]
–
anonymous
comment
Mar 25 at 4:59
Matrices
[deleted]
–
anonymous
comment
Mar 5 at 15:39
Matrices
[deleted]
–
anonymous
comment
Feb 7 at 5:45
Microsoft Natural Ergonomic 4000 Replacement
Thank you so much for sharing your thoughts here, it tells me e…
–
anonymous
comment
Jan 28 at 23:31
Microsoft Natural Ergonomic 4000 Replacement
Oh man, I feel this post. Not sure if you've seen the "new" new…
–
anonymous
…
View All
Log in
Transparency and Alpha Blending
leave this field blank to prove your humanity
Slug
*
A URL path component
Parent page
<root>
rendering/:Article2:3D Rendering (Computer Graphics)
--- rendering/cameras/:Article11:Cameras
--- rendering/matrices/:Article12:Matrices
------ rendering/matrices/projection/:Article14:Projection Matrix
--- rendering/vectors/:Article13:Vectors
--- rendering/geometry/:Article62:3D Geometry
------ rendering/geometry/triangle_meshes/:None
--- rendering/shading/:Article64:Shading
------ rendering/shading/transparency/:Article70:Transparency and Alpha Blending
--- rendering/lights/:Article65:Lights
--- rendering/rasterization/:None
------ rendering/rasterization/deepimage/:Article72:Deep Image
--- rendering/shadows/:Article67:Shadows
--- rendering/spaces/:Article68:Vector Spaces
------ rendering/spaces/tangent_space/:Article69:Tangent Space
------ rendering/spaces/clip_space/:Article89:Clip Space
--- rendering/rotations/:None
--- rendering/images/:Article74:<unset>:Images
------ rendering/images/mipmapping/:Article75:<unset>:Mipmapping
--- rendering/materials/:None
opengl/:Article3:OpenGL Tutorials
--- opengl/oit/:Article7:Order Independent Transparency (OIT)
--- opengl/framebuffer/:Article71:The Framebuffer
meta/:Article4:Pages About This Site
--- meta/contribute/:Article5:Contributing
--- meta/bugs/:Article9:Bugs
--- meta/about/:Article10:Why does this website exist?
The parent page this belongs to.
Article title
*
Article revisions must have a non-empty title
Article body
*
Transparency is the visual effect of an object being partially see-through. In computer graphics it typically refers to *alpha blending*. This is where two colours are mixed by an *alpha* ratio. To make a surface see-through, it is mixed with the colour behind it. The colour behind it may be the result of mixing other surface colours. Blending is often order dependent, requiring sorting as discussed later. There are a number of blending operations, but the most common is alpha blending by Porter and Duff. Physically, alpha models a statistical surface coverage. An example is dust and dirt on clear glass, or a fine spray of paint, where a microscopic portion is fully opaque and the rest fully transparent. The alpha value is the ratio between opaque and transparent parts. Alpha blending can be seen as an antialiasing technique, approximating tiny surface details and avoiding the expense of modelling and rendering them. Coloured glass is a common transparency example, although this implies an absorption effect which isn't modelled by classic alpha blending. # Alpha Blending The following equation overlays or mixes a foreground colour $F$ with background $B$ given the ratio $\alpha$. $$\alpha F + (1 - \alpha) B$$ This equation, also called the *over* operator is the most common. # Transparency Multiple transparent surfaces are handled by starting with the background colour and blending each surface onto it in order from farthest to nearest. colour = background foreach surface colour = blend(colour, surface) In some cases it's useful to blend starting with the front surface and going back. In this case, a *visibility* value must be maintained. This gives a portion of remaining colour that can be added. This is scaled down by the transmittance, $1 - \alpha$ at each surface. vis = 1 colour = 0 foreach surface colour += surface * surfaceAlpha * vis vis *= 1 - surfaceAlpha colour += background * vis This approach is sometimes referred to as the *under* operator as colour from a surface behind the blended group is added. # Visibility Rather than blending surfaces in turn, an alternative approach to solving transparency is to find surface visibility by another means. This allows an unordered sum of surface colours: $$ C = \sum S \cdot S_\alpha \cdot \mathsf{vis}(S)$$ Where $C$ is the result, $S$ is the surface colour and $\mathsf{vis}$ is some function that gives the visibility of the surface, as in the under blending approach above. Although sorting is necessary for correct transparency, the colours themselves don't need sorting, only the alpha values to give the function $\mathsf{vis}$. The concept of a statistical visibility is a great tool to better understand transparency and alpha blending. It is also particularly useful in approximate transparency techniques, where the $\mathsf{vis}$ function is hard coded, approximated or compressed to allow fast unordered blending. # Saturation Blending Alpha blending assumes an even statistical coverage at each surface but this is not always the case. If the opaque parts of partially transparent surfaces perfectly overlap, only the front surface will be visible. Alternatively, if all opaque portions of a surface are visible through the gaps of the transparent surfaces in front of it then the visibility scaling factor should be ignored. That is until there are no more gaps left. This is where saturation blending comes in. vis = 1 colour = 0 foreach surface colour += colour * surfaceAlpha * vis vis = max(0, vis - surfaceAlpha) colour += background * vis This must be done in order of nearest to farthest. An example usage is rasterization antialiasing where a fragment's alpha is set to the portion of the triangle covering a pixel. Triangles are rendered from front to back and it is assumed that further contributions to that pixel will be from other triangles filling the remaining area.
Toggle Preview
Edit message
*
A description of the changes made
Discard Draft
Save Draft
leave this field blank to prove your humanity
Flag
the thing you clicked
for moderator attention.
Reason choice:
Spam, promoting, advertising without disclosure
Rude, inappropriate, generally offensive
Too arrogant or demeaning to others
Other
Reason:
The reason for raising the flag
Error