Graphics Reference
In-Depth Information
Variabl e Type Description
gl_LastFragDepthARM float Reads the existing framebuffer depth value. a
gl_LastFragStencilARM int Reads the existing framebuffer stencil value.
a The returned depth value is in window coordinate space.
Tab l e 3. 2. New built-in variables introduced with the GL_ARM_shader_framebuffer_fetch_depth
_stencil extension.
#extension GL ARM shader framebuffer fetch depth stencil : enable
precision highp float ;
uniform float uTwoXNear ; // 2.0 ￿ near
uniform float uFarPlusNear ; // far + near
uniform float uFarMinusNear ; // far
near
vec2 pack16 ( float x )
{ vec2 p ;
p . y = fract ( x ￿ 255.0);
p . x = x
p . y / 255.0;
return p ;
}
void main ( void )
{ // convert from exponential depth to linear
float Depth = uTwoXNear /( uFarPlusNear
gl_LastFragDepthARM ￿
uFarMinusNear );
// compute moments
float m1 = Depth ;
float m2 = Depth ￿ Depth ;
// store and pack for RGBA8 texture format
gl FragColor = vec4 ( pack16 ( m1 ), pack16 ( m2 ));
}
Listing 3.3. Sample that creates a variance shadow map [Donnelly and Lauritzen 06] in
a single pass. The benefit of this approach is that there's no need to invoke the fragment
shader while writing geometry to depth. This fragment shader is used as a final resolve
shader to convert the depth into variance moments.
3.2.3 Limitations
These extensions have a couple of limitations:
When multisampling is enabled the gl_LastFragColorARM , gl_LastFragDepth
ARM ,and gl_LastFragStencilARM built-in variables will return a value that
is between the minimum and maximum of the samples values.
The GL_ARM_shader_framebuffer_fetch extension does not work with multi-
ple render targets.
Search WWH ::




Custom Search