From 99358c4c41371777046cfdbe1ce444e4cca722df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 29 Mar 2025 19:59:07 +0100 Subject: [PATCH] Shaders: add GenericGL::TextureArrayCoordinates. --- doc/changelog.dox | 2 ++ src/Magnum/Shaders/GenericGL.h | 28 ++++++++++++++++++---- src/Magnum/Shaders/Test/GenericGL_Test.cpp | 4 ++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index efc53428c..8d4d6f941 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -422,6 +422,8 @@ See also: @ref Shaders::Generic::SecondaryJointIds, @ref Shaders::Generic::Weights and @ref Shaders::Generic::SecondaryWeights attributes for GPU skinning support (see also [mosra/magnum#441](https://github.com/mosra/magnum/pull/441)) +- New @ref Shaders::GenericGL::TextureArrayCoordinates attribute for shaders + accepting three-component texture array coordinates - GPU skinning support in @ref Shaders::FlatGL, @ref Shaders::PhongGL and @ref Shaders::MeshVisualizerGL2D / @ref Shaders::MeshVisualizerGL3D (see also [mosra/magnum#444](https://github.com/mosra/magnum/pull/444) and diff --git a/src/Magnum/Shaders/GenericGL.h b/src/Magnum/Shaders/GenericGL.h index 6eb1e8ba2..2229e1920 100644 --- a/src/Magnum/Shaders/GenericGL.h +++ b/src/Magnum/Shaders/GenericGL.h @@ -74,9 +74,7 @@ future use, with no attribute definition implemented yet. 1 -@ref TextureCoordinates - -* *Reserved* --- third component for a layer +@ref TextureCoordinates / @ref TextureArrayCoordinates @@ -290,11 +288,30 @@ template struct GenericGL { /** * @brief 2D texture coordinates * - * @ref Magnum::Vector2 "Vector2". Corresponds to + * @ref Magnum::Vector2 "Vector2". Use either this or the + * @ref TextureArrayCoordinates attribute. Corresponds to * @ref Trade::MeshAttribute::TextureCoordinates. */ typedef GL::Attribute<1, Vector2> TextureCoordinates; + #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief 2D array texture coordinates + * @m_since_latest + * + * @ref Magnum::Vector3 "Vector3". Use either this or the + * @ref TextureCoordinates attribute. Currently doesn't have a + * corresponding @ref Trade::MeshAttribute. + * @requires_gl30 Extension @gl_extension{EXT,texture_array} + * @requires_gles30 Texture arrays are not available in OpenGL ES 2.0. + * @requires_webgl20 Texture arrays are not available in WebGL 1.0. + */ + /* Not naming this TextureCoordinates3D as that's semantically something + else, plus texture arrays are not on ES2 while 3D textures are. The name + for 3D coords would then be TextureVolumeCoordinates I think. */ + typedef GL::Attribute<1, Vector3> TextureArrayCoordinates; + #endif + /** * @brief Three-component vertex color * @@ -541,6 +558,9 @@ struct BaseGenericGL { }; typedef GL::Attribute<1, Vector2> TextureCoordinates; + #ifndef MAGNUM_TARGET_GLES2 + typedef GL::Attribute<1, Vector3> TextureArrayCoordinates; + #endif typedef GL::Attribute<2, Magnum::Color3> Color3; typedef GL::Attribute<2, Magnum::Color4> Color4; #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/Shaders/Test/GenericGL_Test.cpp b/src/Magnum/Shaders/Test/GenericGL_Test.cpp index 721e99dc5..41dbb1357 100644 --- a/src/Magnum/Shaders/Test/GenericGL_Test.cpp +++ b/src/Magnum/Shaders/Test/GenericGL_Test.cpp @@ -60,6 +60,10 @@ void GenericGL_Test::glslMatch() { CORRADE_COMPARE(TEXTURECOORDINATES_ATTRIBUTE_LOCATION, GenericGL2D::TextureCoordinates::Location); CORRADE_COMPARE(TEXTURECOORDINATES_ATTRIBUTE_LOCATION, GenericGL3D::TextureCoordinates::Location); + #ifndef MAGNUM_TARGET_GLES2 + CORRADE_COMPARE(TEXTURECOORDINATES_ATTRIBUTE_LOCATION, GenericGL2D::TextureArrayCoordinates::Location); + CORRADE_COMPARE(TEXTURECOORDINATES_ATTRIBUTE_LOCATION, GenericGL3D::TextureArrayCoordinates::Location); + #endif CORRADE_COMPARE(COLOR_ATTRIBUTE_LOCATION, GenericGL2D::Color3::Location); CORRADE_COMPARE(COLOR_ATTRIBUTE_LOCATION, GenericGL3D::Color3::Location);