GLES2: Support for GL_OES_standard_derivatives (fixes wall brightening when available) (#1276)

This commit is contained in:
20kdc
2020-09-03 08:38:17 +01:00
committed by GitHub
parent 1a453a0d23
commit 7736882da2
3 changed files with 16 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ uniform highp mat4 shadowMatrix;
highp vec2 occludeDepth(highp vec2 diff, sampler2D shadowMap, highp float mapOffsetY)
{
highp float angle = atan(diff.y, -diff.x) + PI + radians(135.0);
#ifdef HAS_DFDX
#ifdef HAS_MOD
angle = mod(angle, 2.0 * PI);
#else
angle -= floor(angle / (2.0 * PI)) * (2.0 * PI);

View File

@@ -29,6 +29,7 @@ namespace Robust.Client.Graphics.Clyde
private bool _hasGLMapBufferOes;
private bool _hasGLMapBufferRange;
private bool _hasGLPixelBufferObjects;
private bool _hasGLStandardDerivatives;
private bool _hasGLFenceSync;
@@ -70,6 +71,7 @@ namespace Robust.Client.Graphics.Clyde
CheckGLCap(ref _hasGLMapBuffer, "map_buffer", (2, 0));
CheckGLCap(ref _hasGLMapBufferRange, "map_buffer_range", (3, 0));
CheckGLCap(ref _hasGLPixelBufferObjects, "pixel_buffer_object", (2, 1));
CheckGLCap(ref _hasGLStandardDerivatives, "standard_derivatives", (2, 1));
}
else
{
@@ -91,6 +93,7 @@ namespace Robust.Client.Graphics.Clyde
CheckGLCap(ref _hasGLMapBufferOes, "map_buffer_oes", exts: "GL_OES_mapbuffer");
CheckGLCap(ref _hasGLMapBufferRange, "map_buffer_range", (3, 0));
CheckGLCap(ref _hasGLPixelBufferObjects, "pixel_buffer_object", (3, 0));
CheckGLCap(ref _hasGLStandardDerivatives, "standard_derivatives", (3, 0), "GL_OES_standard_derivatives");
}
// TODO: Enable these on ES 3.0
@@ -137,7 +140,8 @@ namespace Robust.Client.Graphics.Clyde
"map_buffer",
"map_buffer_range",
"pixel_buffer_object",
"map_buffer_oes"
"map_buffer_oes",
"standard_derivatives"
};
foreach (var cvar in cvars)

View File

@@ -141,12 +141,21 @@ namespace Robust.Client.Graphics.Clyde
GLShader? vertexShader = null;
GLShader? fragmentShader = null;
var versionHeader = "#version 140\n#define HAS_DFDX\n";
var versionHeader = "#version 140\n#define HAS_MOD\n";
if (_isGLES)
{
// GLES2 uses a different GLSL versioning scheme to desktop GL.
versionHeader = "#version 100\n#define HAS_VARYING_ATTRIBUTE\n";
if (_hasGLStandardDerivatives)
{
versionHeader += "#extension GL_OES_standard_derivatives : enable\n";
}
}
if (_hasGLStandardDerivatives)
{
versionHeader += "#define HAS_DFDX\n";
}
if (_hasGLFloatFramebuffers)