Surface normal to screen angle
- by Tannz0rz
I've been struggling to get this working. I simply wish to take a surface normal and convert it to a screen angle.
As an example, assuming we're working with the highlighted surface on the sphere below, where the arrow is the normal, the 2D angle would obviously be PI/4 radians.
Here's one of the many things I've tried to no avail:
float4 A = v.vertex;
float4 B = v.vertex + float4(v.normal, 0.0);
A = mul(VP, A);
B = mul(VP, B);
A.xy = (0.5 * (A.xy / A.w)) + 0.5;
B.xy = (0.5 * (B.xy / B.w)) + 0.5;
o.theta = atan2(B.y - A.y, B.x - A.x);
I'm finally at my wit's end. Thanks for any and all help.