In Unreal Engine 4.27 I am currently trying to create a material (shader) that maps a texture onto a quad using the screen space coordinates from a specific camera. If I am using the current active camera ScreenAlignedUvs node works perfect. The problem however is that in my scene I have 2 cameras, one whose screen space uvs will be used when rendering the texture, and the other which will needs to use the UVs of the first camera. For illustration purposes you can picture the mesh this is applied to as a TV screen which looks like a normal TV to everyone except for one person which the TV appears to follow. To this special person the TV basically appears to be a portal. The picture below is a rough drawing of the example (Red is the special person and their view, Blue is a normal person, Black is the TV, Green are the u part of the uv coordinates).

enter image description here

I would also like to point out that I am aware there could be issues when the main camera is not viewing parts of the mesh that is visible to secondary cameras. In this case I think it is fair for the UVs to be undefined/random.

Here is an example of the current scripts I am using with @DMGregories hit about using the VP matrix of the camera.

Blueprint (Event Tick function) enter image description here

Material enter image description here

While debugging UE returned a projection view matrix of:

[-0.000002,  1.0,        0.0,       0.0]
[-1.0,      -0.000002,   0.0,       0.0]
[0.0,        0.0,        1.777778,  0.0]
[299.999969, 0.00067, -355.555573, 10.0]

For a camera located at: (0, 300, 200)

Facing a plane at: (0, -300, 200)

During this test the UVs are always (1.0, 1.0) for some reason.


1 Answer 1


After a lot of testing/trial and error I was finally able to figure out the effect. Before I jump into it some credit goes to DMGregory for providing the original mapping algorithm and a bit of debugging advice, I am not sure why but his and my comment chain disappeared after I updated the original question with more information.

There were several issues with my original design: 1.) The first pin in a vector parameter are the RGB/XYZ channels (does not include A/W) 2.) The result of the dot product function in the material is a scalar number, not a vector. This means that they should not be added together but instead appended together to create a single vector. 3.) As DMGregory suggested, the matrix needed to be transposed. 4.) The W value of the plane needs to be written to the A value of the color (this was in the original image but I accidentally removed this while testing).

You can see the final result below (I realize this looks just like a normal UV map at the moment) enter image description here

Blueprint Update enter image description here

Blueprint Helper Functions enter image description here

enter image description here

Shader enter image description here

  • \$\begingroup\$ Nice work! I deleted the comments once the question was updated to incorporate the suggestions — we usually treat comments as transient and prefer to avoid persistent conversation threads here. \$\endgroup\$
    – DMGregory
    Sep 30, 2022 at 9:59
  • \$\begingroup\$ I'll keep that in mind, although I can't say I'd recommend that since it can be helpful to refer back to them while working on the task. It also makes it a bit difficult to see the process people went through to work out the answer if it is not explicitly listen in the answer or updates. \$\endgroup\$ Sep 30, 2022 at 11:04
  • \$\begingroup\$ That's the point: that information belongs explicitly in the questions and answers. It should be possible to get the whole story of the problem and solution without reading a back-and-forth comment thread. That's one of the things that makes StackExchange Q&A more friendly for future reference than forum threads, where you have to re-play the whole history to figure out what you're supposed to do. \$\endgroup\$
    – DMGregory
    Sep 30, 2022 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .