Change of Basis

He arrives at the similarity transformation 11 minutes into the video.Ok, now that we all agree the change of basis formula is fully general and fully correct, let’s get weird.One Weird Trick: Partial Change of BasisI didn’t like that this transformation required two matrix multiplies (modulo optimization) per transform and had to be applied to every point, transform and normal (etc) in the asset; and again, this can be particularly slow for animation — so can’t we avoid it?.The knowledge of the internet will tell you, “no, it can’t be avoided, suck it up”, but this isn’t completely true, assuming you’re comfortable with a a few caveats.Let’s think about how the change of basis transformation manifests in our data..Assume we have a chain of transforms applied to a vertex position..In a real asset, we have tons of other data, but this limited view of the world is enough to illustrate the idea..Our goal is to transform a point from object space to world space..Assuming T0..T2 are 4×4 matrix transforms, V is a 4×1 vector position to be transformed, our matrix multiplication looks like this when applying the fully general change of basis:V' = P * T0 * inverse(P) * P * T1 * inverse(P) * P * T2 * inverse(P) * P * VAll those matrix multiplies look extremely redundant, can’t we operate in an intermediate space and only apply the conversion when we’re done?.Well yes, but we’d like to avoid having to write this code explicitly in every shader in the system..Instead, we leverage the fact that we know the rendering pipeline, that despite having many arbitrary transformations, data ultimately results in 4×1 vectors which are strictly positions (i.e. the -Z scale trick works).V' = P * T0 * T1 * T2 * VThat’s a huge reduction in work!.Only the root transform needs to be converted and all other data can remain in its native coordinate space..This works because T0..T2 and V are in the same coordinate space, so rotations work as expected..Additionally, the final output transformation P converts the resulting point correctly, since by definition it cannot be a rotation (it’s just a position)..Finally the camera is in the space which P outputs, so the resulting scene appears correct.. More details