Skip to content

Instantly share code, notes, and snippets.

@progschj
Last active December 6, 2022 15:16
Show Gist options
  • Save progschj/e658ffb22439a444864a9109ff4d372c to your computer and use it in GitHub Desktop.
Save progschj/e658ffb22439a444864a9109ff4d372c to your computer and use it in GitHub Desktop.

EXT_INSTANCE_ARRAY_MATRIX

Introduces the "arrayMatrix" instance subtype.

Parameters:

Name Type Description
group GROUP Group to be instanced, required
array.transform ARRAY1D of FLOAT32_MAT4 Array of transforms, required
array.id ARRAY1D of UINT32 optional array of ids

For evey matrix in the array.transform array the group is placed in the scene transformed by that matrix.

EXT_SKELETAL_TRANSFORM

Introduces the "skeletal" instance subtype.

"skeletal" instance Parameters:

Name Type Description
group GROUP Group to be instanced, required
bone.transform ARRAY1D of FLOAT32_MAT4 Array of transforms, required
id UINT32 Object id

Geometries with a vertex.position array parameter additionally have the following parameters

Geometry Parameters:

Name Type Description
vertex.boneWeight ARRAY1D of FLOAT32_VEC4 bone weight
vertex.boneIndex ARRAY1D of UINT32_VEC4 bone index

If the geometry is instanced by a non-skeletal instance subtype these parameters are not used.

If the geometry is instanced by a skeletal instance subtype the the transform is calculated per vertex as:

transform = boneWeight.x*bone.transform[boneIndex.x]
          + boneWeight.y*bone.transform[boneIndex.y]
          + boneWeight.z*bone.transform[boneIndex.z]
          + boneWeight.w*bone.transform[boneIndex.w]

If a geometry without these parameters is instanced by a skeletal instance subtype vertex.boneWeight and vertex.boneIndex are treated as if they were (0, 0, 0, 1) and will therefore use bone.transform[0] per above formula.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment