Here’s a vertex shader that warps instances to look at an object

The lookAt mat is created like so:

mat3 lookAtPoint(vec3 eye, vec3 at) {
vec3 localUp = vec3(0, 1, 0); // temp sop space up vector
vec3 fwd = normalize(at - eye); // direction to look at position
vec3 right = normalize(cross(localUp, fwd)); // right vector of direction
vec3 up = normalize(cross(fwd, right)); // up vector of direction
return mat3(right, up, fwd);
}

I’m also interpolating between the original verticies and the modified ones based on the height of the vertex. This sticks the monkey head to floor and creates the nice warping effect. Remove this to just have the head rotate without sticking.

Nice work! And great technique of interpolating the vertices to make the monkey more organic Really gives an expression to the guy
Also thank you for sharing the look-at matrix calculation, those can be quite tricky without the knowledge of linear algebra.

I wanted to point out there is 1 small issue with the calculation when the look-at position is directly above the camera. This will set ‘fwd’ vector equal to localUp, the cross product in this case will return all zeros. Then normalizing a vec3(0) will result in NaN’s and will eventually make the monkey disappear. You would need to check manually if the two vectors are equal and if so take another axis to do the cross products.

Though did you know about TDRotateToVector() (described here Write a GLSL Material - Derivative under ‘matrix functions’)? It can be used to calculate the same matrix, but already does this equal check for you. You could use it something like:

Ah great! That’s indeed the best approach to learn I think as well.
What really helped me understanding linear algebra was the MIT lectures by Gilbert Strang (https://www.youtube.com/playlist?list=PL49CF3715CB9EF31D). He’s an amazing teacher!
Though I don’t know the book you’re working through, but it sounds like it’s quite complete as well