WPO Lookat

I found a way to convert the FindLookAtRotation in HLSL and have a 100% shader based look at (except feeding the look at position)

LookAt Code:

X = normalize(end-start);
float3 upvector = X.z < 0.9999 ? float3(0,0,1) : float3(1,0,0);
Y = normalize(cross(upvector, X));
Z = cross(X, Y);

return 0;

This way you could have a material parameter collection for the target position and update hundreds of instances at almost no tick cost.

3 Likes