diff --git a/src/Magnum/Shaders/Generic.h b/src/Magnum/Shaders/Generic.h
index 9322b1054..e15c60def 100644
--- a/src/Magnum/Shaders/Generic.h
+++ b/src/Magnum/Shaders/Generic.h
@@ -374,10 +374,9 @@ Used only if @ref DistanceFieldVectorGL::Flag::TextureTransformation,
*/
struct TextureTransformationUniform {
/** @brief Construct with default parameters */
- constexpr explicit TextureTransformationUniform(DefaultInitT = DefaultInit) noexcept: rotationScaling{Math::IdentityInit}
+ constexpr explicit TextureTransformationUniform(DefaultInitT = DefaultInit) noexcept: rotationScaling{Math::IdentityInit}, offset{0.0f, 0.0f}, layer{0}
#if (defined(CORRADE_TARGET_CLANG) && __clang_major__ < 4) || (defined(CORRADE_TARGET_APPLE_CLANG) && __clang_major__ < 8)
- /* Otherwise it refuses to constexpr, on 3.8 at least */
- , _pad0{}, _pad1{}
+ , _pad0{} /* Otherwise it refuses to constexpr, on 3.8 at least */
#endif
{}
/** @brief Construct without initializing the contents */
@@ -407,6 +406,15 @@ struct TextureTransformationUniform {
return *this;
}
+ /**
+ * @brief Set the @ref layer field
+ * @return Reference to self (for method chaining)
+ */
+ TextureTransformationUniform& setLayer(UnsignedInt layer) {
+ this->layer = layer;
+ return *this;
+ }
+
/**
* @}
*/
@@ -449,6 +457,14 @@ struct TextureTransformationUniform {
*/
Vector2 offset;
+ /**
+ * @brief Texture layer
+ *
+ * Descibes which layer of a texture array to use. Default value is
+ * @cpp 0.5f @ce.
+ */
+ UnsignedInt layer;
+
/* warning: Member __pad0__ is not documented. FFS DOXYGEN WHY DO YOU THINK
I MADE THOSE UNNAMED, YOU DUMB FOOL */
#ifndef DOXYGEN_GENERATING_OUTPUT
@@ -456,11 +472,6 @@ struct TextureTransformationUniform {
#if (defined(CORRADE_TARGET_CLANG) && __clang_major__ < 4) || (defined(CORRADE_TARGET_APPLE_CLANG) && __clang_major__ < 8)
_pad0 /* Otherwise it refuses to constexpr, on 3.8 at least */
#endif
- :32; /* reserved for layer */
- Int
- #if (defined(CORRADE_TARGET_CLANG) && __clang_major__ < 4) || (defined(CORRADE_TARGET_APPLE_CLANG) && __clang_major__ < 8)
- _pad1 /* Otherwise it refuses to constexpr, on 3.8 at least */
- #endif
:32; /* reserved for coordinateSet */
#endif
};
diff --git a/src/Magnum/Shaders/GenericGL.h b/src/Magnum/Shaders/GenericGL.h
index d40318ae3..eb748f994 100644
--- a/src/Magnum/Shaders/GenericGL.h
+++ b/src/Magnum/Shaders/GenericGL.h
@@ -186,9 +186,7 @@ rotation and scale
| 15 |
-@ref TextureOffset (instanced)
-
-* *Reserved* --- third component for a layer
+@ref TextureOffset / @ref TextureOffsetLayer (instanced)
|
* *Reserved* --- a single component \n
@@ -420,8 +418,9 @@ template struct GenericGL {
* @brief (Instanced) texture offset
* @m_since{2020,06}
*
- * @ref Magnum::Vector2 "Vector2". Currently doesn't have a corresponding
- * @ref Trade::MeshAttribute.
+ * @ref Magnum::Vector2 "Vector2". Use either this or the
+ * @ref TextureOffsetLayer attribute. Currently doesn't have a
+ * corresponding @ref Trade::MeshAttribute.
* @requires_gl33 Extension @gl_extension{ARB,instanced_arrays}
* @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays},
* @gl_extension{EXT,instanced_arrays} or
@@ -430,6 +429,22 @@ template struct GenericGL {
* in WebGL 1.0.
*/
typedef GL::Attribute<15, Vector2> TextureOffset;
+
+ #ifndef MAGNUM_TARGET_GLES2
+ /**
+ * @brief (Instanced) texture offset and layer
+ * @m_since_latest
+ *
+ * @ref Magnum::Vector3 "Vector3", with the last component interpreted as
+ * an integer. Use either this or the @ref TextureOffset attribute.
+ * Currently doesn't have a corresponding @ref Trade::MeshAttribute.
+ * @requires_gl33 Extension @gl_extension{EXT,texture_array} and
+ * @gl_extension{ARB,instanced_arrays}
+ * @requires_gles30 Texture arrays are not available in OpenGL ES 2.0.
+ * @requires_webgl20 Texture arrays are not available in WebGL 1.0.
+ */
+ typedef GL::Attribute<15, Vector3> TextureOffsetLayer;
+ #endif
};
#endif
@@ -462,6 +477,9 @@ struct BaseGenericGL {
#endif
typedef GL::Attribute<15, Vector2> TextureOffset;
+ #ifndef MAGNUM_TARGET_GLES2
+ typedef GL::Attribute<15, Vector3> TextureOffsetLayer;
+ #endif
};
template<> struct GenericGL<2>: BaseGenericGL {
diff --git a/src/Magnum/Shaders/Test/GenericTest.cpp b/src/Magnum/Shaders/Test/GenericTest.cpp
index 0abd1809c..cf0782601 100644
--- a/src/Magnum/Shaders/Test/GenericTest.cpp
+++ b/src/Magnum/Shaders/Test/GenericTest.cpp
@@ -378,6 +378,8 @@ void GenericTest::textureTransformationUniformConstructDefault() {
}));
CORRADE_COMPARE(a.offset, (Vector2{0.0f, 0.0f}));
CORRADE_COMPARE(b.offset, (Vector2{0.0f, 0.0f}));
+ CORRADE_COMPARE(a.layer, 0);
+ CORRADE_COMPARE(b.layer, 0);
constexpr TextureTransformationUniform ca;
constexpr TextureTransformationUniform cb{DefaultInit};
@@ -391,6 +393,8 @@ void GenericTest::textureTransformationUniformConstructDefault() {
}));
CORRADE_COMPARE(ca.offset, (Vector2{0.0f, 0.0f}));
CORRADE_COMPARE(cb.offset, (Vector2{0.0f, 0.0f}));
+ CORRADE_COMPARE(ca.layer, 0);
+ CORRADE_COMPARE(cb.layer, 0);
CORRADE_VERIFY(std::is_nothrow_default_constructible::value);
CORRADE_VERIFY(std::is_nothrow_constructible::value);
@@ -403,6 +407,7 @@ void GenericTest::textureTransformationUniformConstructNoInit() {
TextureTransformationUniform a;
a.rotationScaling[1] = {2.5f, -3.0f};
a.offset = {2.7f, 0.3f};
+ a.layer = 37;
new(&a) TextureTransformationUniform{NoInit};
{
@@ -411,6 +416,7 @@ void GenericTest::textureTransformationUniformConstructNoInit() {
#endif
CORRADE_COMPARE(a.rotationScaling[1], (Vector2{2.5f, -3.0f}));
CORRADE_COMPARE(a.offset, (Vector2{2.7f, 0.3f}));
+ CORRADE_COMPARE(a.layer, 37);
}
CORRADE_VERIFY(std::is_nothrow_constructible::value);
@@ -422,12 +428,14 @@ void GenericTest::textureTransformationUniformConstructNoInit() {
void GenericTest::textureTransformationUniformSetters() {
TextureTransformationUniform a;
a.setTextureMatrix(Matrix3::translation({2.6f, 0.3f})*
- Matrix3::rotation(90.0_degf));
+ Matrix3::rotation(90.0_degf))
+ .setLayer(37);
CORRADE_COMPARE(a.rotationScaling, (Matrix2x2{
Vector2{ 0.0f, 1.0f},
Vector2{-1.0f, 0.0f}
}));
CORRADE_COMPARE(a.offset, (Vector2{2.6f, 0.3f}));
+ CORRADE_COMPARE(a.layer, 37);
}
}}}}
|