diff --git a/doc/changelog.dox b/doc/changelog.dox index 00b1c766d..041ee7a07 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -197,6 +197,12 @@ See also: - Texture coordinate transformation in @ref Shaders::DistanceFieldVector, @ref Shaders::Flat, @ref Shaders::Phong and @ref Shaders::Vector +- New attribute definitions and an location allocation scheme in + @ref Shaders::Generic --- @ref Shaders::Generic::Tangent4, + @ref Shaders::Generic::Bitangent, @ref Shaders::Generic::ObjectId plus + @ref Shaders::Generic::TransformationMatrix, + @ref Shaders::Generic::NormalMatrix and + @ref Shaders::Generic::TextureOffset for instancing @subsubsection changelog-latest-new-trade Trade library @@ -515,6 +521,18 @@ See also: was deprecated in 2019.10 is now removed. Usually a deprecated feature is kept for at least a year before removal, but in this case it was severely limiting multithreaded applications and removing it was necessary. +- Locations of generic shader attributes was changed in order to accomodate + for new attributes and use cases. This may break custom shaders if these + rely on generic attribute definitions or are used together with + @ref MeshTools::compile(). To avoid further breakages you're advised to + reuse the definitions from @ref Shaders::Generic (and propagating them to + shader code as well) instead of hardcoding the locations directly. + - @ref Shaders::Generic::Color3 / @ref Shaders::Generic::Color4 location + changed from @cpp 3 @ce to @cpp 2 @ce + - @ref Shaders::Generic::Normal location changed from @cpp 2 @ce to + @cpp 5 @ce + - @ref Shaders::Generic::Tangent location changed from @cpp 4 @ce to + @cpp 3 @ce - Removed remaining APIs deprecated in version 2018.04: - @cpp Audio::Buffer::Format @ce, use @ref Audio::BufferFormat instead - @cpp Shaders::*Vector::setVectorTexture() @ce, diff --git a/src/Magnum/Shaders/Generic.h b/src/Magnum/Shaders/Generic.h index 18f223882..0b496a24f 100644 --- a/src/Magnum/Shaders/Generic.h +++ b/src/Magnum/Shaders/Generic.h @@ -43,6 +43,191 @@ namespace Magnum { namespace Shaders { Definitions common for majority of shaders in the @ref Shaders namespace, allowing mesh or a framebuffer configured for a generic shader to be used with any of them. See @ref shaders-generic for more information. + +@section Shaders-Generic-allocation Attribute allocation + +The attribute locations are allocated like shown below, with various tradeoffs +as GPUs commonly support only 16 attribtes at most, while the mandated minimum +on OpenGL ES2 and WebGL 1 being only 8. Some locations are only reserved for +future use, with no attribute definition implemented yet. + +@m_class{m-row m-container-inflate} + +@parblock + +@m_class{m-fullwidth} + +
| \# | +Attribute | +Alternative | +Alternative 2 | +
|---|---|---|---|
| 0 | ++@ref Position + | +||
| 1 | ++@ref TextureCoordinates + +* *Reserved* --- third component for a layer + | +||
| 2 | ++@ref Color3 / @ref Color4 (per-vertex or instanced) + | +||
| 3 | ++@ref Tangent / @ref Tangent4 + | ++@ref Tangent + | ++* *Reserved* --- TBN as a @ref Magnum::Quaternion "Quaternion" + | +
| 4 | ++@ref ObjectId (instanced) + +* *Reserved* --- additional components could \n +represent material ID and other indices, which \n +could then be used to fetch additional \n +per-instance properties that wouldn't fit into \n +vertex attributes. + | ++@ref Bitangent + +Provided only as a convenience for models that \n +don't encode bitangent orientation in the last \n +component of @ref Tangent4. If a model needs \n +both bitangents and object ID for instancing, \n +@ref Tangent4 has to be used. + | +|
| 5 | ++@ref Normal + | +||
| 6 | ++* *Reserved* --- vertex weights + | +||
| 7 | ++* *Reserved* --- bone indices + | +||
| 8 | ++@ref TransformationMatrix (instanced) + | ++* *Reserved* --- instanced @ref Magnum::DualQuaternion "DualQuaternion" \n transformation for positions and normals + | +|
| 9 | +|||
| 10 | ++* *Reserved* --- 2nd vertex weights + | +||
| 11 | ++* *Reserved* --- 2nd bone indices + | +||
| 12 | ++@ref NormalMatrix (instanced) + | ++* *Reserved* --- instanced scale for positions + | +|
| 13 | ++* *Reserved* --- instanced texture \n +rotation and scale + | ++* *Reserved* --- 2nd vertex colors + | +|
| 14 | ++* *Reserved* --- 3rd texture coords + | +||
| 15 | ++@ref TextureOffset (instanced) + +* *Reserved* --- third component for a layer + | ++* *Reserved* --- a single component \n +representing instanced texture layer \n +index, UVs being the same always + | ++* *Reserved* --- 2nd texture coords + | +