Page 1 of 1

[Unity][Windows] RenderTexture flipped

Posted: 25 May 2016, 12:03
by tomczak
Hi there,

I've a strange behavior on Windows : When I render my main camera to a Texture2D using a RenderTexture / ReadPixels (e.g to save it as an image file), the Noesis GUI Panel attached to the camera is flipped vertically ! Of course, I cannot simply set up the "Flip vertically" property of the Noesis component, because it would impact the renderer GUI, which is good.

The issue occurs only on Windows Standalone, not on Android (I cannot test on IOS).

Any idea ?

Regards,

Roland Tomczak

Re: [Unity][Windows] RenderTexture flipped

Posted: 25 May 2016, 20:19
by jsantos
So, the issue is happening when you read the pixels of the texture using ReadPixels() ?

The 3D scene rendered by Unity is also flipped I suppose.

Re: [Unity][Windows] RenderTexture flipped

Posted: 26 May 2016, 10:53
by tomczak
Please see the attached picture : Here, the "game" is running in the Unity Editor, but the issue persists in the final Windows build..

Every N ms, the application grabs its screen, using RenderTexture / ReadPixels (so, the main Noesis component must have EnablePostProcess = true), encodes it as JPEG and send it to another application (for supervision purpose).

You'll see that the virtual joypad is flipped, just on the screenshot. However, no issue with the "nested" GUI Panel, such as the car dashboard, and the floating white roadbook sheet.
Flipped-Screenshot.jpg

Re: [Unity][Windows] RenderTexture flipped

Posted: 27 May 2016, 18:30
by sfernandez
Let me see if I understood correctly...

You have a NoesisGUIPanel attached to the main Camera game object.
At some point you set a RenderTexture on the targetTexture of that Camera object, and call camera.Render() to generate a screenshot.
And finally you restore the camera.targetTexture to null to render to the main screen again.

Is that correct?

Unfortunately we don't support that scenario right now, but you can workaround it by tweaking a bit our scripts.
Go to Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs script and create a new method:
public void Update()
{
    LateUpdate();
} 
Then, in your script that generates the screenshot do the following:
var gui = GetComponent<NoesisGUIPanel>();
gui.EnablePostProcess = true;
gui.FlipVertically = true;
gui.Update();
...
var cam = GetComponent<Camera>();
cam.targetTexture = screenshotTex;
cam.Render();
cam.targetTexture = null;
...
gui.EnablePostProcess = false;
gui.FlipVertically = false; 
Hope this helps :)

Re: [Unity][Windows] RenderTexture flipped

Posted: 31 May 2016, 14:19
by tomczak
You have a NoesisGUIPanel attached to the main Camera game object.
At some point you set a RenderTexture on the targetTexture of that Camera object, and call camera.Render() to generate a screenshot.
And finally you restore the camera.targetTexture to null to render to the main screen again.

Is that correct?
You're right, I can send you in private the snippet performing all the job.

Sadly, your solution doesn't really correct the issue :
* The screenshot is OK
* However, the GUI being displayed in the Unity application is "flicking" (switching vertically at a random frequency).

I'll try to workaround the issue with two camera, but the "supervisor" won't have the visual feedback of the GUI of the user (could be better).

Any other idea ?

Regards,
Roland Tomczak

Re: [Unity][Windows] RenderTexture flipped

Posted: 31 May 2016, 20:05
by sfernandez
Please create a ticket in our bugtracker and attach everything I need to reproduce your scenario. I'll see if I can find a way to avoid the flickering problem.