
88 II Lighting
language built-in variable gl_PrimitiveID may be used. To assign a unique ID,
an atomic counter is incremented and passed through to the fragment shader. We
use frustum culling in the geometry shader, which can be implemented efficiently
using bit operations to reduce the number of atomic counter operations.
Early depth testing has to be enabled in the fragment shader to ensure that
the fragment shader is executed for visible fragments only:
layout( early_fragment_tests ) in ;
In the fragment shader a lookup into the memoization cache is performed to
get the physical address of the stored triangle. The return value of the lookup
function ...