How can I get the camera vector in worldspace in a material?
I wanted to create a material that would give me the angle in radians in X and Y between the camera and the object the material is applied to. (I wanted this as a basis for a effect that would change depending on whether I looked to the left, right, top, or bottom of the object).
I'm not a programmer so I wrote down the calculations I thought I'd need in order to get this to work. Basically I figured I would need the WSposition of the object and the WSposition of the camera in order to get the WSvector from the camera to the object. And I would need the WSvector of the camera. Then I could just just normalize those vectors and use a asin to get radians for both of them in WS, and subtract one from the other in order to get the angle in rad between the cameraforward and the direction of the object.
Problem is, apparently for some reason Camera vector gives your the vector of the camera compared to the normal of each pixel? And I have no idea what "cameradirectionvector" does but not what I thought it would.
Is there a way to get the rotation of the camera in a material blueprint or is there something I'm missing? I'm guessing I might be able to do it by making it a dynamic material and driving a few parameters through blueprints but since you directly have the "cameravector" node in the material blueprint editor I figured it should logically be possible there as well, or is there a reason that's not possible?
Any help would be greatly appreciated
asked Oct 30 '18 at 01:11 PM in Blueprint Scripting
There are multiple nodes in material editor dealing with camera position and "Camera vector" is not what you need, you should use "Camera Position" which gives you the camera position in World Space and also for getting your object position you should use "Actor Position" node instead of "Absolute World Position". Hope it helps
answered Oct 30 '18 at 02:23 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here