• News

• Industries

• Learning & Support

• Community

• Marketplace

# Projecting a texture in an arbitrary direction?

I currently have a screen aligned texture in my material using the ScreenPosition node as the UV coordinates. This works, but I want it to stop moving when the camera rotates while I’m standing still… so I’m looking for an alternative solution.

My idea was to use the vector between the actor position and camera position as a sort of projection direction, but I have no idea how to use this vector to somehow produce usable UV coordinates.

Anyone have any idea how I might accomplish this?

Drew a diagram of what I’m trying to do in case it will help

Any kind of projection can be simply approached as follows. You need to define coordinate system, transform world space fragment position into this coordinate system, and you are done.
To define orthonormal basis for such coordinate system, you need at least two vectors.

One you already have, that being camera position-> actor position vector, call it vector A. Think about getting the others two, B and C. One approach would be taking normalized cross product of vector A and world up direction to get vector B, and cross product of vector A and B to get vector C. After getting these, you transform position to coordinate system, defined by basis of vectors A, B and C, with origin at camera position. After that, you take two axis, which you are interested in, and perform projection as required, to end up having normalized UVs.

Thanks for the response. I thought I understood so I made my best attempt, but I’m definitely doing something wrong. No matter which axes I mask, the projection is not aligned to the camera/actor vector.

Full resolution: &d=1577744613

Ended up having to normalize all the vectors in order to get an output that wasn’t unreadably distorted… not sure if that was the right thing to do though

Where am I going wrong here?

Still looking for help with this if anyone knows