From BreakEnderNerd Alert
Nerd Alert: Why Leaves Glow When the Sun Is Behind Them
By the BreakEnder newsroom ยท
Real leaves let light through. Game leaves are flat cards. Here is how renderers fake translucency, fix ugly normals and stop forests looking like cardboard.
Point the camera toward a low sun in a good-looking forest and the leaves light up yellow-green, like stained glass. Turn around and the same trees look darker and richer. That effect is called translucency, and getting it right is one of the biggest differences between a forest that looks alive and one that looks like painted cardboard.
Leaves are cards
Game trees are rarely modelled leaf by leaf. Artists use "cards": flat rectangles with a picture of a cluster of leaves on them, with the empty parts cut out by an alpha mask (a black-and-white image that says which pixels exist). Hundreds of these cards stuck onto branches make a canopy.
That is efficient, but cards bring two problems. They are flat, so the lighting on them looks flat. And real leaves are thin, so light passes through them, which a normal surface shader does not model at all.
How normal lighting works
Basic lighting uses the surface normal: an arrow pointing straight out of the surface. If the normal faces the sun, the surface is bright; if it faces away, it is dark. The maths is a dot product, a simple multiply-and-add that measures how much two arrows point the same way:
diffuse = max(dot(normal, toSun), 0);
For a leaf with the sun behind it, that gives zero: black. In reality, that is exactly when a leaf looks brightest from your side.
Faking light through the leaf
The common trick adds a second term for light arriving from behind. One popular version, shared publicly by EA's Frostbite team (Frostbite: approximating translucency), checks whether you are looking toward the light through the surface:
back = pow(saturate(dot(toCamera, -toSun)), sharpness) * thinness;
color += leafColor * sunColor * back;
When you look straight into the sun through a leaf, the term is large and the leaf glows. A thickness texture lets artists say where the leaf is thin (glows a lot) and where veins or stems are thick (glow less). Tinting the result toward a warmer, more saturated green mimics how light picks up color inside a leaf. It is not physically exact, but it is cheap and convincing, which is the motto of real-time graphics.
The full physical version of this is subsurface scattering: light entering a material, bouncing around inside and leaving somewhere else. Skin, wax, marble and leaves all do it. NVIDIA's free GPU Gems book has a good chapter on cheap approximations (GPU Gems, chapter 16).
The ugly normals problem
Now the second problem. If each leaf card keeps its real flat normal, the canopy lights like a pile of playing cards: random bright and dark patches depending on how each card happens to be tilted. Players see harsh speckles instead of a soft, round treetop.
Artists fix this by lying about the normals. A common trick is to point each card's normals outward from the centre of the tree, as if the whole canopy were a big sphere or blob. Then the sunny side of the tree is bright and the shady side is dark, smoothly, like a real bush seen from a distance. Tree tools like SpeedTree expose controls for exactly this kind of leaf lighting (SpeedTree docs: lighting leaves and fronds), and artist forums such as Polycount are full of before-and-after comparisons (Polycount thread on tree normals).
Many games blend the two: mostly the fake round normal for the big shape, a little of the real normal for leaf-level detail.
Darkness inside the canopy
Real trees are darker inside, because outer leaves block light. Renderers fake this too. Artists can bake a value into vertex colors that says how deep inside the canopy each leaf sits, and the shader darkens deep leaves. Ambient occlusion, which gets its own Nerd Alert next, adds contact darkness on top.
Two-sided cards and shadows
Leaf cards are drawn from both sides, so the back face must flip its normal or it will light inside out. And cards casting shadows need the same alpha mask in the shadow pass, otherwise trees cast solid rectangular shadows. In some older games you can spot exactly that.
Wind and light together
Here is a lovely side effect. Because leaves sway (see the first Nerd Alert), their angle to the sun changes every frame, so the translucency term flickers gently. That shimmer of light through a moving canopy comes for free from combining two cheap tricks. Some games add a small extra brightness pulse tied to the wind strength to push it further.
Spot it yourself
- Face the sun in a forest. Do the leaves glow? That is a translucency term.
- Look at a bush from the shady side. Smooth gradient or noisy speckles? Smooth means custom normals.
- Look for rectangular shadows under trees in older games: the alpha mask was skipped in the shadow pass.
Glossary
- Card: a flat textured rectangle standing in for many leaves.
- Alpha mask: an image that marks which pixels are solid and which are see-through.
- Normal: an arrow pointing out of a surface, used for lighting.
- Dot product: a cheap calculation of how aligned two directions are.
- Subsurface scattering: light traveling inside a material before coming back out.
Next up we stay with shadows, but tiny ones: ambient occlusion, the soft darkness in corners that makes a scene feel solid.
If this got you curious, Real-Time Rendering, Fourth Edition is the standard textbook on how games draw their frames.
As an Amazon Associate, BreakEnder earns from qualifying purchases.