(FIX FOUND) EasyAR 3.0.1 Unity iOS camera feed upside down using HDR

+5 votes
asked Aug 28, 2019 by spaceagent (1,220 points)
edited Nov 11, 2019 by spaceagent

The camera feed is upside down on iOS devices using Metal graphics API and with HDR enabled in Graphics settings in Unity. It looks like it is a shader problem related to platform-specific rendering differences.

UPDATE: We managed to find the solution and another related Unity bug.

First the problem is with the EasyAR shaders as initially tought is related to platform-specific rendering differences, second it is a problem with how Unity render its camera and how HDR changes that, as we mentioned in this update.

To fix this we modified all EasyAR shaders to flip the texture uv when #if UNITY_UV_STARTS_AT_TOP is true and a script that set forceIntoRenderTexture to true on the Unity camera, that is doing the same thing that enabling HDR do, except the actual HDR effect.

Here is a link with the modified shaders, just enable forceIntoRenderTexture on the Unity camera with a script and it should work.

4 Answers

0 votes
answered Aug 28, 2019 by nigelkp9 (220 points)
Was your video feed rotated 180 degrees, or was it mirrored? In the forum post you linked, they are experiencing a mirrored video feed, I am just wondering as ours is rotated 180 degrees. I implemented your fix and the video is rotated correctly, but the augmented content is still rotated 180 degrees
commented Aug 29, 2019 by spaceagent (1,220 points)
Yes, the video feed was rotated 180 degrees, the forum post is not related directly with this problem, but it shares the same cause. Also in our case the augmented content was always showing the correct way, we had problems only with the camera feed.
Check a sample scene to see if it is a problem from your scene or from EasyAR.
commented Aug 29, 2019 by nigelkp9 (220 points)
Thank you for the suggestion, I will continue on. Seems like I have two separate issues then
0 votes
answered Nov 10, 2019 by rahnaaqmalina (140 points)
the link is not working, can u reupload again the modified shaders, please..
commented Nov 11, 2019 by spaceagent (1,220 points)
I've updated the link, but to let you know, in the end we didn't use this solution because it is still with bugs. For iOS we switched to OpenGLES graphics API, which is fully supported by EasyAR
0 votes
answered Apr 15 by marcin77 (140 points)

I used attached, updated shaders and also changed Camera.forceIntoRenderTexture setting (in CameraImageRenderer class) and now video I'm recording using NatCorder is recorded correctly (not rotated 180deg).

I didn't wanted to change iOS graphics API to GLES3 but I wanted to stick with Metal so I applied described fix and it works for me.

Best regards
0 votes
answered Apr 24 by jinnin0105 (150 points)

This problem is very simple

 - CameraImageRenderer.cs:140

targetCamera.projectionMatrix = projection * e.ImageRotationMatrixGlobal.inverse;


targetCamera.projectionMatrix = projection;

and you can add bool option

if (InverseMatrix)

    targetCamera.projectionMatrix = projection * e.ImageRotationMatrixGlobal.inverse;


    targetCamera.projectionMatrix = projection;

this perfectly works  no need shaders edit

and screen rotation is works

Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.