Fixed using GL_SAMPLE_ALPHA_TO_COVERAGE
A few things were failing when trying to use
GL_SAMPLE_ALPHA_TO_COVERAGE:
- The alpha test should not be skipped when
GL_SAMPLE_ALPHA_TO_COVERAGE is set, otherwise
no computation is performed.
- The alpha reference value was wrong
(the alpha-to-coverage ramp is centered around it)
Change-Id: Ib9849868d267ca49fb3f0112192af8f207d34307
Reviewed-on: https://swiftshader-review.googlesource.com/8308
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/libGLESv2/Device.cpp b/src/OpenGL/libGLESv2/Device.cpp
index 2e7a2e3..da1583f 100644
--- a/src/OpenGL/libGLESv2/Device.cpp
+++ b/src/OpenGL/libGLESv2/Device.cpp
@@ -52,7 +52,7 @@
setDestBlendFactor(BLEND_ZERO);
setCullMode(CULL_COUNTERCLOCKWISE);
setDepthCompare(DEPTH_LESSEQUAL);
- setAlphaReference(0.0f);
+ setAlphaReference(127.5f);
setAlphaCompare(ALPHA_ALWAYS);
setAlphaBlendEnable(false);
setFogEnable(false);
diff --git a/src/Renderer/Context.cpp b/src/Renderer/Context.cpp
index 1a35873..7e44441 100644
--- a/src/Renderer/Context.cpp
+++ b/src/Renderer/Context.cpp
@@ -515,6 +515,7 @@
bool Context::alphaTestActive()
{
+ if(transparencyAntialiasing != TRANSPARENCY_NONE) return true;
if(!alphaTestEnable) return false;
if(alphaCompareMode == ALPHA_ALWAYS) return false;
if(alphaReference == 0.0f && alphaCompareMode == ALPHA_GREATEREQUAL) return false;
diff --git a/src/Renderer/PixelProcessor.hpp b/src/Renderer/PixelProcessor.hpp
index e5ab442..94d52d3 100644
--- a/src/Renderer/PixelProcessor.hpp
+++ b/src/Renderer/PixelProcessor.hpp
@@ -122,7 +122,7 @@
bool alphaTestActive() const
{
- return alphaCompareMode != ALPHA_ALWAYS;
+ return (alphaCompareMode != ALPHA_ALWAYS) || (transparencyAntialiasing != TRANSPARENCY_NONE);
}
bool pixelFogActive() const