Hi, I am trying to reproduce a paper for shader planet. I am generating a plane mesh on which I apply the spatial shader fort vertices displacement. However, I need the plane to always face the camera - it's simple on CPU (look_at function) but I need to do it inside the shader to get a proper VERTEX positions. In the paper there is an equation for computing the Rotation matrix as follows:
My implementation in Godot is as follows:
vec3 w = normalize(cam_pos);
vec3 v = normalize(cross(w, vec3(0,0,1)));
vec3 u = cross(w, v);
mat3 rot_mat = mat3(u, v, w);
My question is: How to apply the rotation matrix rot_mat to rotate the whole mesh to face the camera? I tried to multiply the rotation matrix with vertices and got somewhat meaningfull outcome, but far from correct.
Thanks for any help! ;)