[Closed] AR Passthrough Material
I'm trying to make a Passthrough material to use for hiding models in an AR scene on iOS and Android. Getting the actual camera texture isn't an issue, but getting the UVs to line up with the passthrough background is. I've tried to use Screen Aligned UVs, but they don't seem to work properly in the Vertex Shader on Android*
Screen Aligned Pixel To Pixel UVs provide a somewhat better result, but still not perfect.
This is how I tried setting the UVs up.
Is there a node that I'm missing that can accomplish what I'm trying to do, or am I using these nodes wrong? Any help would be greatly appreciated!
asked Nov 30 '18 at 09:10 PM in Using UE4
Trey Z ♦♦ STAFF
The question has been closed Nov 30 '18 at 09:15 PM by Trey Z for the following reason:
A ScreenPosition node almost works correctly as the input to a GoogleARCorePassthroughCamera node. It gives the screen's UV coordinates in the value from 0-1. The camera's coordinates also use a 0-1 range, but they're for the camera texture's aspect ratio which might not be the same as the screen's aspect ratio. The post processing used for the regular passthrough clips the camera texture at the top and bottom, so we need to modify the V coordinate to do the same.
Here is my material, and an AR scene with a red-tinted passthrough cube placed in it (Galaxy S8).
Note that the material is doing the calculation in the pixel shader. In the vertex shader, it is correct at the triangle vertices but because of texture perspective correction, the texture coordinates are not interpolated linearly across a 3D triangle, leading to a very weird effect.
I also added a ticket, UE-54833 to request a material node to do this more easily, and to automatically deal with edge cases such as portrait rotation, where I expect the camera is clipped horizontally rather than vertically.
answered Nov 30 '18 at 09:14 PM
Trey Z ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here