Graphics Reference
In-Depth Information
Figure 10-5
Alpha Test Using Discard
Example 10-4 gives the fragment shader code for this example.
Example 10-4
Fragment Shader for Alpha Test Using Discard
#version 300 es
precision mediump float;
uniform sampler2D baseMap;
in vec2 v_texCoord;
layout( location = 0 ) out vec4 outColor;
void main( void )
{
vec4 baseColor = texture( baseMap, v_texCoord );
// Discard all fragments with alpha value less than 0.25
if( baseColor.a < 0.25 )
{
discard;
}
else
{
outColor = baseColor;
}
}
In this fragment shader, the texture is a four-channel RGBA texture. The
alpha channel is used for the alpha test. The alpha color is compared with
0.25; if it is less than that value, the fragment is killed using discard .
 
Search WWH ::




Custom Search