- Home /
[CG vertex shader] Surface normal to screen angle
I've been struggling to get this working. I simply wish to take a surface normal and convert it to a screen angle to be used in a post processing effect.
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.
Thanks for any and all help.
Comment
Best Answer
Answer by Nabbz0rz · Jul 02, 2013 at 05:29 AM
Finally found the solution:
float4 p = ComputeScreenPos(float4(v.normal, 1.0));
o.theta = (atan2(p.y, p.x) / 6.28318530717958) + 0.5;
Your answer
![](https://koobas.hobune.stream/wayback/20220613105318im_/https://answers.unity.com/themes/thub/images/avi.jpg)