Graphics Reference
In-Depth Information
#version 300 es
#extension GL EXT shader pixel local storage : enable
precision mediump float ;
__pixel_local_inEXT FragData
{ layout ( r11f_g11f_b10f ) mediump vec3 Color ;
layout ( rgb10_a2 ) mediump vec4 Normal ;
layout ( r11f_g11f_b10f ) mediump vec3 Lighting ;
}
gbuf ;
// Declare fragment shader output .
// Writing to it effectively clears the contents of
// the pixel local
storage.
out vec4 FragColor ;
void main ( void )
{ // read diffuse and lighting values from pixel local gbuf
storage
vec3 diffuse = gbuf . Color ;
vec3 lighting = gbuf . Lighting ;
// write contents to FragColor . This will effectively write
// the color data to the native framebuffer format of the
// currently attached color attachment
FragColor = diffuse ￿ lighting ;
}
Listing 3.10. This example code resolves the contents of the pixel local storage to the
native framebuffer format. This is a very simple shader that modulates the data in the
pixel local storage and writes it to a fragment shader output.
3.4.3 Step 3: Resolve Everything
This step is similar to classic deferred shading implementations we also need to
resolve the pixel local storage to store the color data in the native framebuffer
format. (See Listing 3.10.)
3.4.4 Bandwidth Numbers
The example deferred shading implementation has very different bandwidth usage
when compared to a conventional multiple render target implementation. As
Figure 3.4 shows, using the extensions saves as much as 9
×
total read and write
bandwidth per frame. This also translates into reduced power consumption and
longer battery life, which is very important in mobile devices. Table 3.5 shows
a further breakdown of the graph. The multiple render target implementation is
set up as follows:
RGBA10 A2 for albedo with D24S8 depth/stencil,
RGBA10 A2 for normals,
Search WWH ::




Custom Search