From 171e8a5301631a5cf3cfa16e4564b8e9e0454782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 22 Mar 2020 12:36:38 +0100 Subject: [PATCH] Shaders: remove MeshVisualizer default behavior. It was rendering everything with a plain color, which is rather useless. Moreover it wasn't consistent with TBN visualization where you might actually want only the lines rendered and not the triangle. --- doc/changelog.dox | 3 + src/Magnum/Shaders/MeshVisualizer.cpp | 22 +- src/Magnum/Shaders/MeshVisualizer.frag | 7 +- src/Magnum/Shaders/MeshVisualizer.geom | 4 +- src/Magnum/Shaders/MeshVisualizer.h | 47 +++-- src/Magnum/Shaders/Test/CMakeLists.txt | 2 - .../Shaders/Test/MeshVisualizerGLTest.cpp | 196 ++++++------------ 7 files changed, 117 insertions(+), 164 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index b851a0ada..8ca5ce778 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -530,6 +530,9 @@ See also: @ref Primitives::GridFlag::Normals for naming consistency - @cpp Shaders::MeshVisualizer @ce is deprecated as the shader can now handle both 2D and 3D, use @ref Shaders::MeshVisualizer3D instead +- Default constructor of @ref Shaders::MeshVisualizer3D is deprecated, you're + now required to enable at least one visualization feature when constructing + it - @cpp Shaders::MeshVisualizer::setTransformationProjectionMatrix() @ce is deprecated on the 3D variant, use separate @ref Shaders::MeshVisualizer3D::setTransformationMatrix() and diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index 172957077..cb433ba96 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -69,10 +69,10 @@ MeshVisualizerBase::MeshVisualizerBase(FlagsBase flags): _flags{flags} { GL::Version MeshVisualizerBase::setupShaders(GL::Shader& vert, GL::Shader& frag, const Utility::Resource& rs) const { #ifndef MAGNUM_TARGET_GLES const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); - CORRADE_INTERNAL_ASSERT(!_flags || _flags & FlagBase::NoGeometryShader || version >= GL::Version::GL320); + CORRADE_INTERNAL_ASSERT(_flags & FlagBase::NoGeometryShader || version >= GL::Version::GL320); #elif !defined(MAGNUM_TARGET_WEBGL) const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200}); - CORRADE_INTERNAL_ASSERT(!_flags || _flags & FlagBase::NoGeometryShader || version >= GL::Version::GLES310); + CORRADE_INTERNAL_ASSERT(_flags & FlagBase::NoGeometryShader || version >= GL::Version::GLES310); #else const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); #endif @@ -96,6 +96,8 @@ GL::Version MeshVisualizerBase::setupShaders(GL::Shader& vert, GL::Shader& frag, } MeshVisualizerBase& MeshVisualizerBase::setColor(const Color4& color) { + CORRADE_ASSERT(_flags & FlagBase::Wireframe, + "Shaders::MeshVisualizer::setColor(): the shader was not created with wireframe enabled", *this); setUniform(_colorUniform, color); return *this; } @@ -117,6 +119,9 @@ MeshVisualizerBase& MeshVisualizerBase::setWireframeWidth(const Float width) { } MeshVisualizer2D::MeshVisualizer2D(const Flags flags): Implementation::MeshVisualizerBase{Implementation::MeshVisualizerBase::FlagBase(UnsignedByte(flags))} { + CORRADE_ASSERT(flags & (Flag::Wireframe & ~Flag::NoGeometryShader), + "Shaders::MeshVisualizer2D: at least Flag::Wireframe has to be enabled", ); + Utility::Resource rs{"MagnumShaders"}; GL::Shader vert{NoCreate}; GL::Shader frag{NoCreate}; @@ -177,8 +182,8 @@ MeshVisualizer2D::MeshVisualizer2D(const Flags flags): Implementation::MeshVisua #endif { _transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); - _colorUniform = uniformLocation("color"); if(flags & Flag::Wireframe) { + _colorUniform = uniformLocation("color"); _wireframeColorUniform = uniformLocation("wireframeColor"); _wireframeWidthUniform = uniformLocation("wireframeWidth"); _smoothnessUniform = uniformLocation("smoothness"); @@ -190,8 +195,8 @@ MeshVisualizer2D::MeshVisualizer2D(const Flags flags): Implementation::MeshVisua /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES setTransformationProjectionMatrix({}); - setColor(Color3(1.0f)); if(flags & Flag::Wireframe) { + setColor(Color3(1.0f)); /* Viewport size is zero by default */ setWireframeColor(Color3{0.0f}); setWireframeWidth(1.0f); @@ -224,10 +229,15 @@ MeshVisualizer2D& MeshVisualizer2D::setSmoothness(const Float smoothness) { MeshVisualizer3D::MeshVisualizer3D(const Flags flags): Implementation::MeshVisualizerBase{Implementation::MeshVisualizerBase::FlagBase(UnsignedByte(flags))} { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + CORRADE_ASSERT(flags & ((Flag::Wireframe|Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection) & ~Flag::NoGeometryShader), + "Shaders::MeshVisualizer3D: at least one visualization feature has to be enabled", ); CORRADE_ASSERT(!(flags & Flag::NoGeometryShader && flags & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)), "Shaders::MeshVisualizer3D: geometry shader has to be enabled when rendering TBN direction", ); CORRADE_ASSERT(!(flags & Flag::BitangentDirection && flags & Flag::BitangentFromTangentDirection), "Shaders::MeshVisualizer3D: Flag::BitangentDirection and Flag::BitangentFromTangentDirection are mutually exclusive", ); + #else + CORRADE_ASSERT(flags & (Flag::Wireframe & ~Flag::NoGeometryShader), + "Shaders::MeshVisualizer3D: at least Flag::Wireframe has to be enabled", ); #endif Utility::Resource rs{"MagnumShaders"}; @@ -323,8 +333,8 @@ MeshVisualizer3D::MeshVisualizer3D(const Flags flags): Implementation::MeshVisua { _transformationMatrixUniform = uniformLocation("transformationMatrix"); _projectionMatrixUniform = uniformLocation("projectionMatrix"); - _colorUniform = uniformLocation("color"); if(flags & Flag::Wireframe) { + _colorUniform = uniformLocation("color"); _wireframeColorUniform = uniformLocation("wireframeColor"); _wireframeWidthUniform = uniformLocation("wireframeWidth"); } @@ -350,8 +360,8 @@ MeshVisualizer3D::MeshVisualizer3D(const Flags flags): Implementation::MeshVisua #ifdef MAGNUM_TARGET_GLES setTransformationMatrix({}); setProjectionMatrix({}); - setColor(Color3(1.0f)); if(flags & Flag::Wireframe) { + setColor(Color3(1.0f)); /* Viewport size is zero by default */ setWireframeColor(Color3{0.0f}); setWireframeWidth(1.0f); diff --git a/src/Magnum/Shaders/MeshVisualizer.frag b/src/Magnum/Shaders/MeshVisualizer.frag index 8b72d6307..7ca72e3af 100644 --- a/src/Magnum/Shaders/MeshVisualizer.frag +++ b/src/Magnum/Shaders/MeshVisualizer.frag @@ -44,7 +44,7 @@ #extension GL_NV_shader_noperspective_interpolation: require #endif -#ifndef TBN_DIRECTION +#if defined(WIREFRAME_RENDERING) && !defined(TBN_DIRECTION) #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 1) #endif @@ -54,7 +54,6 @@ uniform lowp vec4 color #endif ; -#if defined(WIREFRAME_RENDERING) && !defined(TBN_DIRECTION) #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 2) #endif @@ -64,7 +63,6 @@ uniform lowp vec4 wireframeColor #endif ; #endif -#endif #ifdef WIREFRAME_RENDERING #ifdef EXPLICIT_UNIFORM_LOCATION @@ -183,8 +181,7 @@ void main() { fragmentColor = mix(wireframeColor, color, nearest); #endif - /* Plain color rendering */ #else - fragmentColor = color; + #error neither wireframe or TBN direction is enabled, huh? #endif } diff --git a/src/Magnum/Shaders/MeshVisualizer.geom b/src/Magnum/Shaders/MeshVisualizer.geom index ffbfcc718..c5b9659bb 100644 --- a/src/Magnum/Shaders/MeshVisualizer.geom +++ b/src/Magnum/Shaders/MeshVisualizer.geom @@ -41,7 +41,7 @@ uniform lowp vec2 viewportSize; /* defaults to zero */ layout(triangles) in; -#if defined(TANGENT_DIRECTION) || defined(BITANGENT_DIRECTION) || defined(NORMAL_DIRECTION) +#if (defined(TANGENT_DIRECTION) || defined(BITANGENT_DIRECTION) || defined(NORMAL_DIRECTION)) && defined(WIREFRAME_RENDERING) #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 1) #endif @@ -59,7 +59,9 @@ uniform lowp vec4 wireframeColor = vec4(0.0, 0.0, 0.0, 1.0) #endif ; +#endif +#if defined(TANGENT_DIRECTION) || defined(BITANGENT_DIRECTION) || defined(NORMAL_DIRECTION) #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 8) #endif diff --git a/src/Magnum/Shaders/MeshVisualizer.h b/src/Magnum/Shaders/MeshVisualizer.h index 80a4c2a0c..c8c12c2be 100644 --- a/src/Magnum/Shaders/MeshVisualizer.h +++ b/src/Magnum/Shaders/MeshVisualizer.h @@ -86,15 +86,16 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerBase: public GL::AbstractShaderProgram @m_since_latest Uses the geometry shader to visualize wireframe of 3D meshes. You need to -provide the @ref Position attribute in your triangle mesh. By default, the -shader renders the mesh with a white color in an identity transformation. Use +provide the @ref Position attribute in your triangle mesh. Use @ref setTransformationProjectionMatrix(), @ref setColor() and others to configure the shader. @image html shaders-meshvisualizer2d.png width=256px -This shader is a 2D variant of @ref MeshVisualizer3D with mostly identical -workflow. See its documentation for more information. +The shader expects that you enable wireframe visualization by passing an +appropriate @ref Flag to the constructor --- there's no default behavior with +nothing enabled. The shader is a 2D variant of @ref MeshVisualizer3D with +mostly identical workflow. See its documentation for more information. */ class MAGNUM_SHADERS_EXPORT MeshVisualizer2D: public Implementation::MeshVisualizerBase { public: @@ -153,8 +154,10 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer2D: public Implementation::MeshVisuali /** * @brief Constructor * @param flags Flags + * + * At least @ref Flag::Wireframe is expected to be enabled. */ - explicit MeshVisualizer2D(Flags flags = {}); + explicit MeshVisualizer2D(Flags flags); /** * @brief Construct without creating the underlying OpenGL object @@ -209,7 +212,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer2D: public Implementation::MeshVisuali * @brief Set base object color * @return Reference to self (for method chaining) * - * Initial value is @cpp 0xffffffff_rgbaf @ce. + * Initial value is @cpp 0xffffffff_rgbaf @ce. Expects that + * @ref Flag::Wireframe is enabled. */ MeshVisualizer2D& setColor(const Color4& color) { return static_cast(Implementation::MeshVisualizerBase::setColor(color)); @@ -255,14 +259,17 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer2D: public Implementation::MeshVisuali /** @brief 3D mesh visualization shader -Uses the geometry shader to visualize wireframe of 3D meshes. You need to -provide the @ref Position attribute in your triangle mesh. By default, the -shader renders the mesh with a white color in an identity transformation. Use -@ref setTransformationProjectionMatrix(), @ref setColor() and others to -configure the shader. +Uses the geometry shader to visualize wireframe or tangent space of 3D meshes. +You need to provide the @ref Position attribute in your triangle mesh at the +very least. Use @ref setTransformationProjectionMatrix(), @ref setColor() and +others to configure the shader. @image html shaders-meshvisualizer3d.png width=256px +The shader expects that you enable either wireframe visualization or tangent +space visualization by passing an appropriate @ref Flag to the constructor --- +there's no default behavior with nothing enabled. + @section Shaders-MeshVisualizer-wireframe Wireframe visualization Wireframe visualization is done by enabling @ref Flag::Wireframe. It is done @@ -538,8 +545,21 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer3D: public Implementation::MeshVisuali /** * @brief Constructor * @param flags Flags + * + * At least @ref Flag::Wireframe or one of @ref Flag::TangentDirection, + * @ref Flag::BitangentFromTangentDirection, + * @ref Flag::BitangentDirection, @ref Flag::NormalDirection is + * expected to be enabled. */ - explicit MeshVisualizer3D(Flags flags = {}); + explicit MeshVisualizer3D(Flags flags); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Constructor + * @m_deprecated_since_latest Use @ref MeshVisualizer3D(Flags) instead. + */ + explicit CORRADE_DEPRECATED("use MeshVisualizer3D(Flags) instead") MeshVisualizer3D(): MeshVisualizer3D{{}} {} + #endif /** * @brief Construct without creating the underlying OpenGL object @@ -638,7 +658,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer3D: public Implementation::MeshVisuali * @brief Set base object color * @return Reference to self (for method chaining) * - * Initial value is @cpp 0xffffffff_rgbaf @ce. + * Initial value is @cpp 0xffffffff_rgbaf @ce. Expects that + * @ref Flag::Wireframe is enabled. */ MeshVisualizer3D& setColor(const Color4& color) { return static_cast(Implementation::MeshVisualizerBase::setColor(color)); diff --git a/src/Magnum/Shaders/Test/CMakeLists.txt b/src/Magnum/Shaders/Test/CMakeLists.txt index 3d232c177..6be23fb21 100644 --- a/src/Magnum/Shaders/Test/CMakeLists.txt +++ b/src/Magnum/Shaders/Test/CMakeLists.txt @@ -151,8 +151,6 @@ if(BUILD_GL_TESTS) MagnumShadersTestLib MagnumOpenGLTester FILES - FlatTestFiles/defaults.tga - FlatTestFiles/colored3D.tga MeshVisualizerTestFiles/defaults-wireframe2D.tga MeshVisualizerTestFiles/defaults-wireframe3D.tga MeshVisualizerTestFiles/wireframe2D.tga diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index c9997aa84..53d1d1194 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -69,7 +69,11 @@ struct MeshVisualizerGLTest: GL::OpenGLTester { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void constructWireframeGeometryShader2D(); void constructGeometryShader3D(); + #endif + void construct2DNoFeatureEnabled(); + void construct3DNoFeatureEnabled(); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void construct3DGeometryShaderDisabledButNeeded(); void construct3DConflictingBitangentInput(); #endif @@ -86,15 +90,11 @@ struct MeshVisualizerGLTest: GL::OpenGLTester { void renderSetup(); void renderTeardown(); - void renderDefaults2D(); - void renderDefaults3D(); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void renderDefaultsWireframe2D(); void renderDefaultsWireframe3D(); void renderDefaultsTangentBitangentNormal(); #endif - void render2D(); - void render3D(); void renderWireframe2D(); void renderWireframe3D(); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) @@ -131,7 +131,6 @@ constexpr struct { const char* name; MeshVisualizer2D::Flags flags; } ConstructData2D[] { - {"", {}}, {"wireframe w/o GS", MeshVisualizer2D::Flag::Wireframe|MeshVisualizer2D::Flag::NoGeometryShader}, }; @@ -139,7 +138,6 @@ constexpr struct { const char* name; MeshVisualizer3D::Flags flags; } ConstructData3D[] { - {"", {}}, {"wireframe w/o GS", MeshVisualizer3D::Flag::Wireframe|MeshVisualizer3D::Flag::NoGeometryShader} }; @@ -267,7 +265,8 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() { Containers::arraySize(ConstructGeometryShaderData3D)); #endif - addTests({ + addTests({&MeshVisualizerGLTest::construct2DNoFeatureEnabled, + &MeshVisualizerGLTest::construct3DNoFeatureEnabled, #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) &MeshVisualizerGLTest::construct3DGeometryShaderDisabledButNeeded, &MeshVisualizerGLTest::construct3DConflictingBitangentInput, @@ -283,17 +282,13 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() { #endif }); - addTests({&MeshVisualizerGLTest::renderDefaults2D, - &MeshVisualizerGLTest::renderDefaults3D, - #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - &MeshVisualizerGLTest::renderDefaultsWireframe2D, + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + addTests({&MeshVisualizerGLTest::renderDefaultsWireframe2D, &MeshVisualizerGLTest::renderDefaultsWireframe3D, - &MeshVisualizerGLTest::renderDefaultsTangentBitangentNormal, - #endif - &MeshVisualizerGLTest::render2D, - &MeshVisualizerGLTest::render3D}, + &MeshVisualizerGLTest::renderDefaultsTangentBitangentNormal}, &MeshVisualizerGLTest::renderSetup, &MeshVisualizerGLTest::renderTeardown); + #endif addInstancedTests({&MeshVisualizerGLTest::renderWireframe2D}, Containers::arraySize(WireframeData2D), @@ -429,6 +424,29 @@ void MeshVisualizerGLTest::constructGeometryShader3D() { } #endif +void MeshVisualizerGLTest::construct2DNoFeatureEnabled() { + std::ostringstream out; + Error redirectError{&out}; + /* This isn't a feature flag */ + MeshVisualizer2D{MeshVisualizer2D::Flag::NoGeometryShader}; + CORRADE_COMPARE(out.str(), + "Shaders::MeshVisualizer2D: at least Flag::Wireframe has to be enabled\n"); +} + +void MeshVisualizerGLTest::construct3DNoFeatureEnabled() { + std::ostringstream out; + Error redirectError{&out}; + /* This isn't a feature flag */ + MeshVisualizer3D{MeshVisualizer3D::Flag::NoGeometryShader}; + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + CORRADE_COMPARE(out.str(), + "Shaders::MeshVisualizer3D: at least one visualization feature has to be enabled\n"); + #else + CORRADE_COMPARE(out.str(), + "Shaders::MeshVisualizer3D: at least Flag::Wireframe has to be enabled\n"); + #endif +} + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MeshVisualizerGLTest::construct3DGeometryShaderDisabledButNeeded() { #ifndef MAGNUM_TARGET_GLES @@ -505,12 +523,17 @@ void MeshVisualizerGLTest::setWireframeNotEnabled2D() { std::ostringstream out; Error redirectError{&out}; - MeshVisualizer2D shader; - shader.setWireframeColor({}) + /* The constructor asserts for at least some feature being enabled (which + is just wireframe in case of 2D), so fake it with a NoCreate */ + MeshVisualizer2D shader{NoCreate}; + shader + .setColor({}) + .setWireframeColor({}) .setWireframeWidth({}) .setSmoothness({}); CORRADE_COMPARE(out.str(), + "Shaders::MeshVisualizer::setColor(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer::setWireframeColor(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer::setWireframeWidth(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer2D::setSmoothness(): the shader was not created with wireframe enabled\n"); @@ -520,12 +543,18 @@ void MeshVisualizerGLTest::setWireframeNotEnabled3D() { std::ostringstream out; Error redirectError{&out}; - MeshVisualizer3D shader; - shader.setWireframeColor({}) + /* The constructor asserts for at least some feature being enabled (which + is just wireframe in case we're not on desktop or ES3.2), so fake it + with a NoCreate */ + MeshVisualizer3D shader{NoCreate}; + shader + .setColor({}) + .setWireframeColor({}) .setWireframeWidth({}) .setSmoothness({}); CORRADE_COMPARE(out.str(), + "Shaders::MeshVisualizer::setColor(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer::setWireframeColor(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer::setWireframeWidth(): the shader was not created with wireframe enabled\n" "Shaders::MeshVisualizer3D::setSmoothness(): the shader was not created with wireframe or TBN direction enabled\n"); @@ -533,20 +562,26 @@ void MeshVisualizerGLTest::setWireframeNotEnabled3D() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MeshVisualizerGLTest::setTangentBitangentNormalNotEnabled3D() { + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::ARB::geometry_shader4::string() + std::string(" is not supported")); + #else + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::geometry_shader::string() + std::string(" is not supported")); + #endif + std::ostringstream out; Error redirectError{&out}; - MeshVisualizer3D shader; + MeshVisualizer3D shader{MeshVisualizer3D::Flag::Wireframe}; shader.setNormalMatrix({}) .setLineWidth({}) - .setLineLength({}) - .setSmoothness({}); + .setLineLength({}); CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizer3D::setNormalMatrix(): the shader was not created with TBN direction enabled\n" "Shaders::MeshVisualizer3D::setLineWidth(): the shader was not created with TBN direction enabled\n" - "Shaders::MeshVisualizer3D::setLineLength(): the shader was not created with TBN direction enabled\n" - "Shaders::MeshVisualizer3D::setSmoothness(): the shader was not created with wireframe or TBN direction enabled\n"); + "Shaders::MeshVisualizer3D::setLineLength(): the shader was not created with TBN direction enabled\n"); } #endif @@ -586,58 +621,6 @@ void MeshVisualizerGLTest::renderTeardown() { _color = GL::Renderbuffer{NoCreate}; } -void MeshVisualizerGLTest::renderDefaults2D() { - GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); - - MeshVisualizer2D{} - .draw(circle); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || - !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) - CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); - - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - /* SwiftShader has differently rasterized edges on four pixels */ - const Float maxThreshold = 238.0f, meanThreshold = 0.298f; - #else - /* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */ - const Float maxThreshold = 238.0f, meanThreshold = 0.298f; - #endif - CORRADE_COMPARE_WITH( - /* Dropping the alpha channel, as it's always 1.0 */ - Containers::arrayCast(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels()), - Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), - (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); -} - -void MeshVisualizerGLTest::renderDefaults3D() { - GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); - - MeshVisualizer3D{} - .draw(sphere); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || - !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) - CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); - - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - /* SwiftShader has differently rasterized edges on four pixels */ - const Float maxThreshold = 238.0f, meanThreshold = 0.298f; - #else - /* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */ - const Float maxThreshold = 238.0f, meanThreshold = 0.298f; - #endif - CORRADE_COMPARE_WITH( - /* Dropping the alpha channel, as it's always 1.0 */ - Containers::arrayCast(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels()), - Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), - (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); -} - #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MeshVisualizerGLTest::renderDefaultsWireframe2D() { #ifndef MAGNUM_TARGET_GLES @@ -772,67 +755,6 @@ void MeshVisualizerGLTest::renderDefaultsTangentBitangentNormal() { } #endif -void MeshVisualizerGLTest::render2D() { - GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); - - MeshVisualizer2D{} - .setColor(0x9999ff_rgbf) - .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) - .draw(circle); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || - !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) - CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); - - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - /* SwiftShader has differently rasterized edges on four pixels */ - const Float maxThreshold = 170.0f, meanThreshold = 0.133f; - #else - /* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */ - const Float maxThreshold = 170.0f, meanThreshold = 0.456f; - #endif - CORRADE_COMPARE_WITH( - /* Dropping the alpha channel, as it's always 1.0 */ - Containers::arrayCast(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels()), - Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"), - (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); -} - -void MeshVisualizerGLTest::render3D() { - GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); - - MeshVisualizer3D{} - .setColor(0x9999ff_rgbf) - .setTransformationMatrix( - Matrix4::translation(Vector3::zAxis(-2.15f))* - Matrix4::rotationY(-15.0_degf)* - Matrix4::rotationX(15.0_degf)) - .setProjectionMatrix( - Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)) - .draw(sphere); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || - !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) - CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); - - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - /* SwiftShader has differently rasterized edges on four pixels */ - const Float maxThreshold = 170.0f, meanThreshold = 0.133f; - #else - /* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */ - const Float maxThreshold = 170.0f, meanThreshold = 0.456f; - #endif - CORRADE_COMPARE_WITH( - /* Dropping the alpha channel, as it's always 1.0 */ - Containers::arrayCast(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels()), - Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"), - (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); -} - void MeshVisualizerGLTest::renderWireframe2D() { auto&& data = WireframeData2D[testCaseInstanceId()]; setTestCaseDescription(data.name);