Graphics › The frame
Transparency: Opaque, Masked, Translucent
Know first: Color is numbers, Depth buffer: what is closer to the camera
A wall hides everything behind it. A leaf hides the view only where there is leaf. Glass and smoke let part of the view through. To the graphics card these are three ways to draw a pixel: replace what is there, throw the pixel away, or blend it with what is already drawn. Blending turns out to be the lerp from the color lesson. It also explains why transparent things are drawn last and where their sorting goes wrong, why smoke is expensive, and why distant foliage thins out and grows a dark fringe. This is the fourth lesson of the course “How an engine draws a frame.”
Why this matters
In the lesson on the depth buffer, transparent things got a single line: they test depth, but they do not write their own. That line hides a whole topic, and an environment artist runs into it all the time:
- foliage is expensive, yet from far away a tree crown thins out and you can see through it;
- there is a dark fringe around the leaves that is not in the texture;
- smoke above water shows up, then slips under the water as soon as you move the camera;
- the back wall of a glass bottle is drawn on top of the front wall;
- thick smoke drops the frame rate more than a whole city does.
All of this follows from one choice: how a new color lands on top of a color that is already drawn.