Revert "Optimized discarding in fragment shaders on ES3"

This reverts commit dcb52b40df.
This commit is contained in:
Roman Kuznetsov 2017-06-28 13:08:37 +03:00 committed by Daria Volvenkova
parent dcb52b40df
commit ef57012e1c
4 changed files with 6 additions and 18 deletions

View file

@ -25,6 +25,8 @@ void main()
lowp vec4 finalColor = color;
finalColor.a = finalColor.a * u_opacity * (1.0 - alpha);
discardFragmentIfDepthEnabled(finalColor.a == 0.0);
if (finalColor.a == 0.0)
discard;
gl_FragColor = finalColor;
}

View file

@ -11,6 +11,7 @@ void main()
{
vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
discardFragmentIfDepthEnabled(finalColor.a < 0.01);
if (finalColor.a < 0.01)
discard;
gl_FragColor = finalColor;
}

View file

@ -46,18 +46,3 @@ vec4 samsungGoogleNexusWorkaround(vec4 color)
return color;
#endif
}
// This function discards fragment in ES2 mode or writes maximum value to the depth buffer
// in ES3. It helps to avoid 'discard' invocation in cases when usual depth buffer mode is in use.
void discardFragmentIfDepthEnabled(bool needDiscard)
{
#ifdef GLES3
if (needDiscard)
gl_FragDepth = 1.0;
else
gl_FragDepth = gl_FragCoord.z;
#else
if (needDiscard)
discard;
#endif
}

View file

@ -39,7 +39,7 @@ void main()
delta.xy = abs(L - vec2(Lleft, Ltop));
vec2 edges = step(kThreshold, delta.xy);
if (dot(edges, vec2(1.0, 1.0)) == 0.0)
discard;
discard;
// Calculate right and bottom deltas.
float Lright = dot(texture2D(u_colorTex, v_offset1.xy).rgb, kWeights);