Download

orientation of texture UVs to point towards camera world location?

I hope I can get a solution to this problem I am having.

My lit sphere material I normally use works great in most cases, but in VR if i turn my head the material mimics my head rotation which ruins the effect. I need the UVs to point at the camera, not mimic the camera’s orientation…

Here is my material:
3e7d39f78a0dff065d13512678d96fba05b2f70d.png

How can I change this so that the orientation POINTS to my cameras world location?

Please help :frowning:

There is an answerhub post that might be somewhat relevant to your problem.

Thanks Deathrey, i’ll check that out!

That looks exactly like the same problem I am having! so, is this the solution?
dd7becfa462217ca27a7a4e59af55d354750975b.jpeg

this was the drawing i made to try to explain to a coworker:
HELPME!.png

When do use “0,0,1” transform Tangent->View, this performs the same transform for everything since the view transform is fixed from the camera orientation.

Instead, do normalize(ObjectPosition - CameraPosition) as the vector and it will work as you want.

FWIW, we have a jira task to make this an option for particle sprites but I do not think it has been worked on yet.

Hey Ryan thanks for the response! That makes sense.

when you say subtract the positions to obtain a vector, I was investigating that approach but I didnt know how to implement the vector. Could you post a .png of how the material network would look?

I have found that matcaps work great for creating billowing smoke. it gives me softer edges than fresnel and gives me the volume of spheres. I have also used matcap materials for explosions:

Boom:https://youtube.com/watch?v=dHBoExX0vFsSmoke:https://youtube.com/watch?v=EgbKzSFeobs
I created these a couple years ago in UDK3.

Thanks for all your hard work Ryan! I love UE4!

You subtract CameraPosition from ObjectPosition and then normalize the result. That should be it.

i got that far but then what do i do with the result? do I plug it into a transform node? sorry if my question is a bit noob, I don’t have much of a math background, but i do understand some basic concepts regarding math in graphics.
so i understand how to get a direction between to coordinates, and i understand a normalized vector. i just dont know how to use the vector.

Where in this material network would the normalized vector go?
dd7becfa462217ca27a7a4e59af55d354750975b.jpeg

would it replace the transform node?

You use it directly in place of the 0,0,1 Transform Tangent->View that you had. It should be the same except it will face the camera slightly differently.

hey so when I use the matcap method above, my textures are being rotated 90 degrees. any idea why? whats the simplest way to correct this?

Looks like you appended your vector as G, R which rotates 90 degrees. This operation is called a swizzle and performs a 90 degree rotation for free.

Append it as R,G instead to not rotate. So you dont need to append, just component mask R,G.