OndrejNepozitek / Edgar-Unity

Unity Procedural Level Generator
https://ondrejnepozitek.github.io/Edgar-Unity/docs/introduction
MIT License
817 stars 70 forks source link

strange behaviour fog #83

Closed luisgsoft closed 3 years ago

luisgsoft commented 3 years ago

Hi! I've configured fog for dungeon and for minimap. Dungeon has fow component and minimap has fow alternative camera script In editor runs all perfect. Nice job. In android minimap runs ok, but dungeon is alwais in fog. I can walk and minimap is revealing while main camera is always in fog. If i put fog of war component in minimap camera, and remove it from main_camera, minimap runs ok too.

So the main problem is with main_camera in android. I have a cinemachine vCam running, i don't know if this can be the problem.

Ah. And fog of war example scene is not running on my unity editor (2020.1.9)

OndrejNepozitek commented 3 years ago

So, if I understand you correctly:

Are you using LWRP, URP or the builtin render pipeline? In which version of Unity editor does it work? Can you try if it works without the cinemachine vCam?

pvalium commented 3 years ago

Unity 2020.9 Built in pipeline

El jue., 12 nov. 2020 20:45, Ondřej Nepožitek notifications@github.com escribió:

So, if I understand you correctly:

  • fog works when you enter play mode inside the editor
  • fog does not work for the main camera when you build the game for android

Are you using LWRP, URP or the builtin render pipeline? In which version of Unity editor does it work?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OndrejNepozitek/Edgar-Unity/issues/83#issuecomment-726300785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE25VMWPWVYFLSZKZ77PBALSPQ3MBANCNFSM4TTWDFEQ .

pvalium commented 3 years ago

2020.1.9*

El jue., 12 nov. 2020 20:51, Luis Miguel Salinas luismisalinas@gmail.com escribió:

Unity 2020.9 Built in pipeline

El jue., 12 nov. 2020 20:45, Ondřej Nepožitek notifications@github.com escribió:

So, if I understand you correctly:

  • fog works when you enter play mode inside the editor
  • fog does not work for the main camera when you build the game for android

Are you using LWRP, URP or the builtin render pipeline? In which version of Unity editor does it work?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OndrejNepozitek/Edgar-Unity/issues/83#issuecomment-726300785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE25VMWPWVYFLSZKZ77PBALSPQ3MBANCNFSM4TTWDFEQ .

OndrejNepozitek commented 3 years ago

I downloaded Unity 2020.1.13f1 (the latest recommended version) to test the android build on the Minimap/FogOfWar example scenes. And it seems like everything works correctly. The fog is working both for the main camera and for the minimap camera. I used the built-in render pipeline. Moreover, the fog of war example scene works as well for me.

Can you try disabling the cinemachine vCam? I've got no experience with that so I cannot really try. Unfortunately, if I cannot reproduce your issue, it is very hard to help you.

pvalium commented 3 years ago

I think that example scene is not running by my physics matrix. I'll try to disable cinemachine cam and i'll inform you about results

Thanks

El jue., 12 nov. 2020 22:54, Ondřej Nepožitek notifications@github.com escribió:

I downloaded Unity 2020.1.13f1 (the latest recommended version) to test the android build on the Minimap/FogOfWar example scenes. And it seems like everything works correctly. The fog is working both for the main camera and for the minimap camera. I used the built-in render pipeline. Moreover, the fog of war example scene works as well for me.

Can you try disabling the cinemachine vCam? I've got no experience with that so I cannot really try. Unfortunately, if I cannot reproduce your issue, it is very hard to help you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OndrejNepozitek/Edgar-Unity/issues/83#issuecomment-726363346, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE25VMWS7AGHFTFXPKW6W2LSPRKQ5ANCNFSM4TTWDFEQ .

pvalium commented 3 years ago

I left you a video: https://youtu.be/GG_NORN87QU

Here you can see: 0.Fow color is green in order to visualize clear 1-Initialize fow. Minimap ok, main camera not 2-Reload fow. Nothing happends 3.Disable fow. Main camera runs ok 4.Enable fow. Main camera freezes. Minimap runs ok, and gameplay are running in bakground. I can move player, but camera not refreshes

I've tried to remove cinemachine. Same result.

OndrejNepozitek commented 3 years ago

Thanks for the video!

Please try to do the following:

I followed this thread - https://forum.unity.com/threads/graphics-blit-not-working-for-android.534835/ - and their issue seems similar to your issue and they said that adding this line helps. I cannot test it myself as my android phone does not have this problem.

Let me know if that helps.

pvalium commented 3 years ago

Yes. This solved this issue!

Thank you!

El vie., 13 nov. 2020 a las 21:11, Ondřej Nepožitek (< notifications@github.com>) escribió:

Thanks for the video!

Please try to do the following:

  • Open the Assets\Edgar\Runtime\FogOfWar\FogOfWar.shader file
  • Try to add ZTest Always right bellow line 17, it should look like this:

    Pass { ZTest Always CGPROGRAM

I followed this thread - https://forum.unity.com/threads/graphics-blit-not-working-for-android.534835/

  • and their issue seems similar to your issue and they said that adding this line helps. I cannot test it myself as my android phone does not have this problem.

Let me know if that helps.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OndrejNepozitek/Edgar-Unity/issues/83#issuecomment-727007386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE25VMTJR6UR3HOMNUQPR73SPWHGBANCNFSM4TTWDFEQ .

OndrejNepozitek commented 3 years ago

Great! I'll include that in the next release/hotfix.

By the way, how is the performance of the fog of war on mobiles? Is it okay?

pvalium commented 3 years ago

Well, performance is improvable. Without fow, i get around 50 fps. With fow, I get around 30fps. With this performance, i'll use it only in minimap

My mobile is Xiaomi miA2 lite updated to last android version

OndrejNepozitek commented 3 years ago

I've got one potential performance improvement in mind. If I manage to make it work, I'll get back to you.

pvalium commented 3 years ago

Perfect. Thanks a lot

El sáb., 14 nov. 2020 12:21, Ondřej Nepožitek notifications@github.com escribió:

I've got one potential performance improvement in mind. If I manage to make it work, I'll get back to you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OndrejNepozitek/Edgar-Unity/issues/83#issuecomment-727191063, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE25VMQ2EBOLNGMT5JYTEWTSPZRZZANCNFSM4TTWDFEQ .

OndrejNepozitek commented 3 years ago

I've sent you an email with 2 modified scripts - FogOfWar.cs and FogOfWarAdditionalCamera.cs. Please put these files in the Assets\Edgar\Runtime\FogOfWar folder and overwrite the old files.

Instead of the OnRenderImage hook, I now use OnPreRender and OnPostRender which should improve the performance mainly on mobile devices. On my PC, the FPS improved from circa 800 to circa 1100.

Let me know if that helps!

pvalium commented 3 years ago

Performance si similar, Maybe around 5 fps more. In my mobile and game, cost of enable fog in main camera is around 15-20 fps loss