|
|
@@ -124,6 +124,11 @@ layout(set = 0, binding = 9, row_major, std140) readonly buffer b_ankiBoneTransf
|
|
|
{
|
|
|
Mat4 u_ankiBoneTransforms[];
|
|
|
};
|
|
|
+
|
|
|
+layout(set = 0, binding = 10, row_major, std140) readonly buffer b_ankiPrevFrameBoneTransforms
|
|
|
+{
|
|
|
+ Mat4 u_ankiPrevFrameBoneTransforms[];
|
|
|
+};
|
|
|
#endif
|
|
|
|
|
|
#if ANKI_INSTANCE_COUNT == 1
|
|
|
@@ -137,6 +142,7 @@ layout(set = 0, binding = 9, row_major, std140) readonly buffer b_ankiBoneTransf
|
|
|
// Globals (always in local space)
|
|
|
Vec3 g_position = in_position;
|
|
|
#if ANKI_PASS == PASS_GB
|
|
|
+Vec3 g_prevPosition = in_position;
|
|
|
Vec2 g_uv = in_uv;
|
|
|
Vec3 g_normal = in_normal;
|
|
|
Vec4 g_tangent = in_tangent;
|
|
|
@@ -147,16 +153,19 @@ Vec4 g_tangent = in_tangent;
|
|
|
void skinning()
|
|
|
{
|
|
|
Mat4 skinMat = u_ankiBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
|
|
|
+ Mat4 prevSkinMat = u_ankiPrevFrameBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
|
|
|
ANKI_UNROLL for(U32 i = 1; i < 4; ++i)
|
|
|
{
|
|
|
skinMat += u_ankiBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
|
|
|
+ prevSkinMat += u_ankiPrevFrameBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
|
|
|
}
|
|
|
|
|
|
- g_position = (skinMat * Vec4(g_position, 1.0)).xyz;
|
|
|
# if ANKI_PASS == PASS_GB
|
|
|
+ g_prevPosition = (prevSkinMat * Vec4(g_position, 1.0)).xyz;
|
|
|
g_tangent.xyz = (skinMat * Vec4(g_tangent.xyz, 0.0)).xyz;
|
|
|
g_normal = (skinMat * Vec4(g_normal, 0.0)).xyz;
|
|
|
# endif
|
|
|
+ g_position = (skinMat * Vec4(g_position, 1.0)).xyz;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
@@ -192,10 +201,23 @@ void parallax()
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-#if ANKI_VELOCITY && ANKI_PASS == PASS_GB
|
|
|
+#if(ANKI_VELOCITY || ANKI_BONES) && ANKI_PASS == PASS_GB
|
|
|
void velocity()
|
|
|
{
|
|
|
- const Vec4 v4 = u_ankiPerInstance[INSTANCE_ID].m_ankiPreviousMvp * Vec4(g_position, 1.0);
|
|
|
+# if ANKI_BONES
|
|
|
+ const Vec3 prevLocalPos = g_prevPosition;
|
|
|
+# else
|
|
|
+ const Vec3 prevLocalPos = g_position;
|
|
|
+# endif
|
|
|
+
|
|
|
+# if ANKI_VELOCITY
|
|
|
+ const Mat4 mvp = u_ankiPerInstance[INSTANCE_ID].m_ankiPreviousMvp;
|
|
|
+# else
|
|
|
+ const Mat4 mvp = u_ankiPerInstance[INSTANCE_ID].m_ankiMvp;
|
|
|
+# endif
|
|
|
+
|
|
|
+ const Vec4 v4 = mvp * Vec4(prevLocalPos, 1.0);
|
|
|
+
|
|
|
const Vec2 prevNdc = v4.xy / v4.w;
|
|
|
|
|
|
const Vec2 crntNdc = gl_Position.xy / gl_Position.w;
|
|
|
@@ -218,7 +240,7 @@ void main()
|
|
|
parallax();
|
|
|
# endif
|
|
|
|
|
|
-# if ANKI_VELOCITY
|
|
|
+# if ANKI_VELOCITY || ANKI_BONES
|
|
|
velocity();
|
|
|
# endif
|
|
|
#else
|
|
|
@@ -362,7 +384,7 @@ void main()
|
|
|
const Vec3 emission = u_ankiPerDraw.m_emission;
|
|
|
# endif
|
|
|
|
|
|
-# if ANKI_VELOCITY
|
|
|
+# if ANKI_VELOCITY || ANKI_BONES
|
|
|
const Vec2 velocity = in_velocity;
|
|
|
# else
|
|
|
const Vec2 velocity = Vec2(-1.0);
|