Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Shape keys #2375

merged 36 commits into from
Nov 6, 2021


Copy link

@QuantumCoderQC QuantumCoderQC commented Nov 2, 2021

This PR implements GPU and texture based shape keys, more commonly known as "morph targets" in game-dev terminology.
Solves #225

Requires armory3d/iron#145

What is possible:

  • Supports a maximum of 32 shape keys per object.
  • Weights of each of the shape keys can be individually set. The resulting mesh is a sum of all shape keys, just like in Blender.
  • Supports displacement and normal maps.
  • Shape keys can be used along with skinned mesh too.
  • Any shape key can be excluded form export by "muting" that shape key in Blender.
  • Shape keys can be enabled or disabled for the entire project in Armory render path settings.
  • Added a new Set Object Shape Key Node to make it easier to set shape keys.
  • The node also supports live patching

How it works:

  • At export, if a mesh has shape keys, displacement of each vertex in a shape key is calculated relative to the Base mesh. Vertex normals are also calculated relative to the ´Base` mesh.
  • This displacement and normal data is scaled to best possible range between 0 to 1 and stored in RGBA32 format
  • The pixels are then packed into best suited power-of-two png image in a dedicated directory MorphTargets
  • At export the mesh containing shape keys will add an additional UV map UVMap_shape_key to read this texture. This does not conflict the already supported maximum of 2 UV maps.
  • This image is read at runtime as a texture in a dedicated morph target shader in the vertex shader.

Missing Features and known issues:

  • Tangent maps are not yet exported. So displacement along the tangents do not work too well.
  • Shape key animations are not yet implemented. Only relative shape keys are supported.
  • Maximum image size for shape key texture is hard coded to be 4096 X 4096 pixels.

Thanks to people at Discord for providing valuable inputs and testing the code.

@MoritzBrueckner MoritzBrueckner added the Release Notes: Changes A pull request that is a feature change, not a fix. Used to generate release notes. label Nov 2, 2021
@luboslenco luboslenco merged commit 263d585 into armory3d:master Nov 6, 2021
Copy link

Wow, amazing!

This was referenced Nov 6, 2021
@QuantumCoderQC QuantumCoderQC deleted the shape-keys branch January 14, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Release Notes: Changes A pull request that is a feature change, not a fix. Used to generate release notes.
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants