2D depth of field shader
Shaders can help us achieve a huge amount of visually interesting effects and give your games the extra something to impress users. This recipe will tackle a very basic implementation of a depth of field postprocessing effect, which will reinforce a cinematic feeling.
The term depth of field comes from film and photography and refers to the distance between the nearest and furthest objects in a scene that appear reasonably sharp. Lenses can focus at a single distance, and the sharpness of objects will decrease as they are positioned away from the point. The human eye itself also works in a similar manner, although it can dynamically adjust the focus point much more easily.
The following diagram illustrates the depth of field ...
Get Libgdx Cross-platform Game Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.