Browse Source

Shaders: enable noperspective in MeshVisualizer properly.

This makes existing tests slightly broken, which is good (if it
wouldn't, the thresholds would be too huge). Since the addition of ES3.2
geometry shaders (which broke this) happened long before there were
rendering tests for shaders, this breakage wasn't caught until now. Of
course proper tests would include the perspective case from the previous
commit since the very beginning, but that's hard to do when you're
testing long after the code was written.

The test files are now RLE-encoded, which makes them significantly
smaller (tho I assume Git would further compress both anyway). Not
updating existing files to RLE yet to avoid repo history bloat, doing
that the next time they get changed.
pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
c880e6293a
  1. 3
      doc/changelog.dox
  2. 2
      src/Magnum/Shaders/MeshVisualizer.frag
  3. 2
      src/Magnum/Shaders/MeshVisualizer.geom
  4. 10
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  5. BIN
      src/Magnum/Shaders/Test/MeshVisualizerTestFiles/wireframe-wide3D.tga
  6. BIN
      src/Magnum/Shaders/Test/MeshVisualizerTestFiles/wireframe3D.tga

3
doc/changelog.dox

@ -432,6 +432,9 @@ See also:
check
- For a @ref Shaders::Phong with zero lights, alpha mask default value was
incorrectly @cpp 0.0f @ce instead of @cpp 0.5f @ce on OpenGL ES
- @ref Shaders::MeshVisualizer3D accidentally didn't enable
@glsl noperspective @ce interpolation on desktop, resulting in minor
wireframe rendering artifacts
@subsection changelog-latest-deprecated Deprecated APIs

2
src/Magnum/Shaders/MeshVisualizer.frag

@ -82,7 +82,7 @@ uniform lowp float smoothness
;
#ifndef NO_GEOMETRY_SHADER
#ifdef GL_NV_shader_noperspective_interpolation
#if !defined(GL_ES) || defined(GL_NV_shader_noperspective_interpolation)
noperspective
#endif
in lowp vec3 dist;

2
src/Magnum/Shaders/MeshVisualizer.geom

@ -44,7 +44,7 @@ layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
/* Interpolate in screen space (if possible) */
#ifdef GL_NV_shader_noperspective_interpolation
#if !defined(GL_ES) || defined(GL_NV_shader_noperspective_interpolation)
noperspective
#endif
out lowp vec3 dist;

10
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -792,8 +792,14 @@ void MeshVisualizerGLTest::renderWireframe3D() {
CORRADE_EXPECT_FAIL_IF(data.flags & MeshVisualizer3D::Flag::NoGeometryShader,
"Line width is currently not configurable w/o geometry shader.");
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has differently rasterized edges on four pixels */
const Float maxThreshold = 170.0f, meanThreshold = 0.327f;
/* SwiftShader has differently rasterized edges on four pixels. On a
GS, if GL_NV_shader_noperspective_interpolation is not supported,
the artifacts are bigger. */
Float maxThreshold = 170.0f, meanThreshold = 0.327f;
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(!(data.flags & MeshVisualizer3D::Flag::NoGeometryShader) && !GL::Context::current().isExtensionSupported<GL::Extensions::NV::shader_noperspective_interpolation>())
meanThreshold = 2.166f;
#endif
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 170.0f, meanThreshold = 1.699f;

BIN
src/Magnum/Shaders/Test/MeshVisualizerTestFiles/wireframe-wide3D.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
src/Magnum/Shaders/Test/MeshVisualizerTestFiles/wireframe3D.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Loading…
Cancel
Save