pr0g / unity-portal-rendering

Super small example of using offscreen render targets to achieve a portal effect in Unity
MIT License
251 stars 40 forks source link

Portal view upside down #5

Closed joavd closed 5 years ago

joavd commented 5 years ago

Each portal's view is upside down, if I try to rotate it 180 degrees so that it becomes normal it stays the same in play mode.

Was it a bug I had while opening the project? Or it's a known bug?

pr0g commented 5 years ago

Hmm can you let me know what platform you're on? Is this Windows? Or running on a device?

Thanks!

Tom

joavd commented 5 years ago

I'm on Windows 10, and opened the project with Unity 2018.3.5f1

The bug is just that the portal view is upside down, if I try to rotate it becomes "right" but when pressing play it goes back to upside down. I can provide screenshots/gifs if needed.

Thank you

pr0g commented 5 years ago

Hmm it must be a DirectX thing, it'll be an issue with the shader for sure. I should be able to repro it later today with a bit of luck.

For now if you go to Assets/Shaders/PortalShader.shader and comment out the uv.y = 1.0 - uv.y, it should fix it, but I need to figure out why the #if block is not working properly...

Thanks!

Tom

On Mon, 11 Feb 2019, 17:08 João Duarte <notifications@github.com wrote:

I'm on Windows 10, and opened the project with Unity 2018.3-5f1-

The bug is just that the portal view is upside down, if I try to rotate it becomes "right" but when pressing play it goes back to upside down. I can provide screenshots/gifs if needed.

Thank you

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pr0g/unity-portal-rendering/issues/5#issuecomment-462409411, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFX8fd4ZHhsqnvROFBeR4V2BggEAvGFks5vMaN1gaJpZM4a0Xl4 .

joavd commented 5 years ago

Sorry to bother while you're out.

Commenting out that line doesnt have any effect in the portal view. Tell me if there's anything I can do to help.

Thanks again

pr0g commented 5 years ago

🤔 hmmm... that is odd, I wasn't expecting that. Very helpful to know though! Let me get back to you when I've got the repro up and running (might be a few hours sorry so don't hold your breath 😉) I'm sure we can figure this out!

pr0g commented 5 years ago

Hello again!

Okay managed to repro it, it's down to this line:

if (_MainTex_TexelSize.y < 0)

if you comment it out, the portal will no longer be flipped (but annoyingly I need this line to have things work on Metal devices…) so I'm trying to figure out what incantation I need to have everything work on all platforms!

I'll try and update it in a bit if I can figure it out :)

Thanks for reporting it!

You should be safe to just change that locally for now

Cheers!

pr0g commented 5 years ago

This should now be fixed! 😄 Please grab latest and observe Portals the right way up! 😊

For reference, please see the section 'Rendering in UV space' of this article - https://docs.unity3d.com/Manual/SL-PlatformDifferences.html for information about the fix.

Thanks!

joavd commented 5 years ago

Thanks a lot for your time! 😄

pr0g commented 5 years ago

Not at all 😊Thanks for reporting the issue! Turns out what I was doing before wasn't quite right 😬Fingers crossed it should work consistently on all platforms now 😄