Camera Facing Materials On 2 Axes


I’m using a method of rotating a material to face the camera found here Stylized Rendering Materials | Unreal Engine Documentation

Custom Node:

float2 output; 
float2 Input1; 
output = atan2 (In.y,In.x); 
return (output);

The material definitely works as it was originally intended, rotating a shrub around the z axis only. My intention was to use this method for a bunch of leaves on a tree but as I’ve found out, leaves on a tree need to be rotated on more than 1 axis.

Can anyone point out to me which part of this method is responsible for locking the rotation to only 1 axes and possibly come up with a suggestion on how to factor in the x or y axis too, so I have not only a yaw but a pitch rotation too.

I thought maybe the masking of the red channel was the reason it only rotated around z, so I also added green channel to the same mask, upon doing so the engine crashes with no error.


Same boat, dont have a clue, It looks very complicated to me, what are those 3.142 value, and people do create these :slight_smile:

here is the solution