tomczak
Topic Author
Posts: 30
Joined: 26 Mar 2014, 10:25

[Unity][Windows] RenderTexture flipped

25 May 2016, 12:03

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
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity][Windows] RenderTexture flipped

25 May 2016, 20:19

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.
 
tomczak
Topic Author
Posts: 30
Joined: 26 Mar 2014, 10:25

Re: [Unity][Windows] RenderTexture flipped

26 May 2016, 10:53

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
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: [Unity][Windows] RenderTexture flipped

27 May 2016, 18:30

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 :)
 
tomczak
Topic Author
Posts: 30
Joined: 26 Mar 2014, 10:25

Re: [Unity][Windows] RenderTexture flipped

31 May 2016, 14:19

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
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: [Unity][Windows] RenderTexture flipped

31 May 2016, 20:05

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.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 26 guests