
356 V Mobile Devices
Lighting Buffer(s)
Lighting calculations
executed in screen
space
Material ID
Normals
World-Space
Positions
Final Result Frame
Render the scene into
a deep frame buffer
(G-buffer)
G-Buffer
Assemble the final
frame and perform
screen-space effects
Compute lighting on
each G-buffer pixel
(no overdraw)
Figure 1.4. Deferred shading pipeline.
uniform sampler2D normalTexture ;
uniform sampler2D positionTexture ;
void main ()
{
vec2 uv = rl_FrameCoord . xy / rl_FrameSize . xy ;
vec4 normal = texture2D ( normalTexture , uv );
vec4 position = texture2D( positionTexture , uv ;
if( normal . w ==0.0) return ; //No fragment was rendered for this
// pix el
IlluminateSurface ...