Blending - Advanced Rendering - Shader Learning

Advanced Rendering

Blending

Task

Create a program that renders a candle with a halo effect. Initially, the halo is rendered without blending. Modify the program to use alpha blending for the halo effect by changing the blending settings in a .properties file.


You can use the Ctrl+Space shortcut while editing the file to see autocomplete suggestions.

Theory

Blending is a technique used to combine the color of a source pixel (the pixel being drawn) with the color of a destination pixel (the pixel already in the framebuffer).


No Blending


When blending is disabled, the colors of the source pixels are directly written to the framebuffer without any modification. In this mode, the source color completely replaces the destination color in the framebuffer.


Alpha Blending


Alpha blending is used to create transparency effects. It combines the source and destination colors based on the alpha value of the source color. The alpha value represents the opacity of the source color, where 0 is fully transparent and 1 is fully opaque.


The blending equation for alpha blending is:

FinalColor = (SrcColor * SrcAlpha) + (DstColor * (1 − SrcAlpha))