AR Passthrough Material

Hi ,

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.

Cheers