Search Unity

Fog of War

Discussion in 'Assets and Asset Store' started by stu_pidd_cow, Oct 11, 2016.

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    @stu_pidd_cow , Oh alright fair enough. Then what about this?

    "
    Also enabling the snap to pixel center seems like it is forcing everything to be under partial fog..
    Disable output to texture also seems to be doing the same thing.
    "

    I used the enable snap to pixel to try and get reduce the flicking, because that is the apparent renamed option. But when I enable it, it looks like everything is under partial fog.. (or does weird thing) This does not happen with older version.

    Also, I am very interested to find out the difference between hardware and software method, in terms of visual and performance..
     
  2. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yeah, there's definitely a bug there. I've fixed it up, but I'm not sure if it's the issue you're talking about. If you send me an email, I can give you a unitypackage to test.

    There's a table in the documentation which should give you the gist of it. Generally though, hardware is still missing some features, but should be much faster if you have a large resolution map and/or lots of units. It's still kinda experimental, so I'll be working on the performance some more.
     
  3. Tommy4421

    Tommy4421

    Joined:
    Nov 12, 2016
    Posts:
    5
    Update: This was solved when I reimported the code, and when I created my own level. The demo level still doesn't work.

    I am using unity 2019.2.9f1 and the Post Processing Stack v2. When I load the PPSv2 example scene i is see the fog, but it's not aligned with the rest of the map. Is there a fix for this?

    Thanks in advance,

    Tom

    upload_2019-12-17_20-27-29.png

    upload_2019-12-17_20-34-46.png
     
    Last edited: Dec 17, 2019
  4. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    That error message is just there because the demo doesn't let you change teams in the PPSv2 (something that I'm working on), but everything else should be fine.

    So reimporting fixed the fog not being aligned?
     
  5. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    30
    Hi @stu_pidd_cow
    Do you have an ETA for the HDRP Update?
    Thanks
     
    Last edited: Jan 16, 2020
  6. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    HDRP is still sorely lacking in information for developing custom processing. Hopefully with 2019.3 coming out soon, I'll be able to get it done. Unfortunately I can't give any reliable ETA.
     
  7. Tommy4421

    Tommy4421

    Joined:
    Nov 12, 2016
    Posts:
    5
    Last edited: Feb 4, 2020
  8. Tommy4421

    Tommy4421

    Joined:
    Nov 12, 2016
    Posts:
    5

    Sorry for the late reaction. Yes, the reimport worked, thanks.
     
  9. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    faolad and Tommy4421 like this.
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi @stu_pidd_cow .

    I was wondering if it is possible to save fog data managed by chunk manager.
    It seems to remember the fogs some how, so I was wondering if there is way to save and reload the fog data so that when game loads save game, it can reload the fog data.
     
  11. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Hmmm yeah you're right. I'll put something in for that asap.
     
  12. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    @stu_pidd_cow , I am currently trying to reduce the GC being generated by the FogOfWarTeam.Update function. occationally it generates like 1.3mb of GC.. any idea where this could potentially come from?
     
  13. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    The only thing I can think of is if you are changing the resolution of the map. I just ran a profile and haven't been able to reproduce it, but I did find one memory allocation in the PPSv2 script (nothing to do with FogOfWarTeam though).
    If you do a deep profile and sort by GC Alloc, you should be able to find roughly where it is. Or you can send me a dump from your profiler and I'll look into it.
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I will look further, but I am thinking this could come from using chunk manager? And happens when chunk swaps the texture? Maybe?
     
  15. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    There will be a memory allocation whenever a new chunk become visible, but I don't think memory should be deallocated, so it shouldn't trigger GC (at least not until the chunk manager resets the chunks).
     
  16. RedEnt

    RedEnt

    Joined:
    Jan 15, 2015
    Posts:
    4
    Can anyone confirm if this plugin works for WebGL?
     
  17. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have done only a bit of testing for WebGL, but it seems to work fine (I don't have a whole lot of experience with WebGL unfortunately). I have uploaded a downloadable version here if you would like to try locally.
     
  18. RedEnt

    RedEnt

    Joined:
    Jan 15, 2015
    Posts:
    4
    Error 500 trying to download. Adding to my drive doesn't solve the issue. Can you upload it somewhere else? Thanks.
     
  19. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Hmmm yeah something went wrong with it. Try this instead.
     
  20. RedEnt

    RedEnt

    Joined:
    Jan 15, 2015
    Posts:
    4
    Purchased it and working fine in WebGL. Thanks.
     
    faolad and stu_pidd_cow like this.
  21. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Any new Update planned?
     
  22. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm still battling with HDRP post processing. Hopefully I can have something up for this coming weekend, although I can't promise anything.
     
    Pandur1982 likes this.
  23. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    FogOfWar v1.21 has just been uploaded to the asset store! It should be available for download in the next few days. Here's what's in it:
    • Added support for HDRP 7.1.8+
    • Changed multithreading in hardware mode warning to an error
    • Improved FogOfWarMinimap performance improvement a bit
    • Added Save() and Load() to FogOfWarChunkManager
    • Improved FogOfWarChunkManager memory display in editor
    • Made FogOfWar shaders automatically included to the always included shader list
    • Fixed "Look rotation viewing vector is zero" warning in 3D demo
    • Added gizmos for FogOfWarTeam map area
    • Added FogOfWarTeam.GetVisibleUnits()
    • Improved platform support for demos
    • Fixed 2D demo no putting chunks into a parent object
    • Put in a hardware accelerated minimap in demo scene

    I know a lot of people are still asking about URP/LWRP support, but this is the situation: Unity has completely removed support for the Post Processing Stack v2 and replaced it with the new volume system. For whatever reason, the new volume system does not have custom post processing capabilities, so it is literally impossible for me to get FogOfWar working with the current release of URP. If your project is heavily dependant on FogOfWar, I would recommend not upgrading to 2019.3 just yet. The moment Unity provides custom post processing support, I will be jumping in to get FoW working ASAP (which should definitely not take as long as HDRP support did). Sorry if this is an inconvenience to anyone!
     
  24. JPDoiron

    JPDoiron

    Joined:
    Jan 11, 2013
    Posts:
    16
    Good job on the asset , thanks

    We have multiple scenes and not all uses the fog of war, however being a default "Before post Process" the Fog of war will try to render , throw warning and display a gray screen whenever the team component is not set.

    I added a Active bool in the class FogOfWarHDRP which allow me to disable it by default and add a Volume Override on the scene I want the FOW.

    You should look into something similar in your next update to allow easy toggle between scenes.

    (or maybe you have another way, and I'm all ear)

    Best regards

    JP
     
  25. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I will definitely put this in for next release. Thanks for pointing it out!
     
  26. SXtheOne

    SXtheOne

    Joined:
    Sep 5, 2018
    Posts:
    21
    Hi,
    Is Fog of War compatible with Unity 2019.3.5f1? Not even one of the samples working for me. I've tried HDRP and 3D with Extras but in HDRP there is no fog, in 3D with Extras there is nothing else but fog (not clearing). I've set up the 3D with Extras (added the two shader to the always include section) but nothing changed. I've also set up most of the HDRP but couldn't setup everything written in the user's guide.
     
  27. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, there appears to be an issue with the latest release. I'm in the process of uploading a fix. Feel free to send me an email and I will give you the fix early.
     
  28. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have uploaded a v1.22 of FogOfWar to the asset store. It's mostly just a small bug fix release. Here's what's in it:
    • Fixed wrong inverse view matrix in legacy and PPSv2 shader
    • Made fog color default to clear for HDRP to work around a unity bug where disabling the volume override doesn't work
    • Made FogOfWar appear in root of volume overrides for HDRP

    It could take a few days for the asset store to approve it, so if you need any of these fixes earlier, feel free to send me an email!
     
  29. SXtheOne

    SXtheOne

    Joined:
    Sep 5, 2018
    Posts:
    21
    Thanks, I'm just starting the project and can live without fog of war for a week or two. As I see the fix will be in store by then so I can wait. :)
     
  30. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hello,

    I just purchased this fog of war asset yesterday and I am having some trouble trying to get it to appear in my scene, but I am also very new to it. I am using HDRP. Using Unity 2019.3.3f1. And HDRP package version 7.1.8. So far no fog of war is showing up in my scene.

    However, I do see the fog of war appearing in the HDRP 3D sample scene that is provided with the asset. Which I'm guessing means I'm simply not setting up the structure of the system properly in my scene somehow.

    What I have currently is a gameobject in my scene with the FogOfWarTeam script component on it like this:
    UnityHD_FogofWarProblem1.jpg


    Then, also, in my post-process volume in my scene, I have the Fog Of War HDRP volume component override.

    When I hit "Play", no fog appears at all. So I'm not sure what I'm missing?

    What is the main script or object that actually creates the Fog of War in the scene? I see the blue rectangle in my Scene view that I'm guessing represents the fog area (in the User Guide it says it should be a red box though).

    Also, in the User Guide (for HDRP), it says to put a FogOfWarHDRP post process order (in the HDRP default settings in the project settings) in the "After Post Process" section. But it won't let me in that order, it says no custom post-process available. However in the "Before Post Process" section, it says the FogOfWarHDRP is available -- so that's where I currently have it -- in the "Before Post Process" section.

    Also something to note, my ground/terrain is not at Y = 0. It is actually at a height of 100 in the scene. Would that affect the system at all? I also have it on a "Ground" layer (Layer 9) that is not the default layer or layer number. Would that be an issue as well?

    In addition to this, I am using a lot of 3rd party assets and shaders from the asset store. For example I'm using the CTS 2019 terrain shader for my ground/terrain. I'm also using NatureManufactura trees and tree shaders, along with a lot of diffusion profiles. Would any of this be a problem as well?

    Thanks for any info, and if you need more info from me I'd be happy to provide it as well.
     
  31. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    You are right about the inconstencies with the documentation. I will fix this up asap.

    Everything you have done is correct. Some things you can check:
    • Does the map (the blue square) align with the map when you look at it vertically in orthographic?
      • You say you have the scene at 100 on the Y axis, maybe try bringing it down to zero just to make sure.
    • Make sure your units have the FogOfWarUnit script on them and that their team index is the same as on the FogOfWarTeam component.
    • Make sure the FogOfWarUnit shape is correct (you can see a visualisation of it in the scene view).
    • Make sure your FogOfWarHDRP post process has the same team as on the FogOfWarTeam component.
    • Make sure FogOfWarTeam's plane is set to XZ.
    • You might want to turn off line of sight on you units (in case you put it on).

    Let me know if you're still having trouble after all that.
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    A client is using this as an overhead map in an RPG, and it's working great so far. One other thing you might want to change in the manual is to mention GetTotalFogValues() in addition to GetCurrentFogValues() in the paragraph on saving and loading. In the RPG case, we want to save everywhere that the player has uncovered since starting, not just what's visible in the current frame.
     
  33. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Thanks, I'll definitely add this.
     
  34. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    Hi Stu_pidd_cow,

    I just recently tested all of what you suggested above in that list, and unfortunately I'm still not seeing any fog of war. Again, I'm a little perplexed, because it's working in the HDRP Sample scene you provided. But not in my scene.

    Any other thoughts of what I might be doing wrong or perhaps might be missing?


    Some of my thoughts are: The fog of war doesn't work with my terrain shader I'm using (called CTS terrain from the asset store). Or maybe I need a flat plane just underneath my terrain that your fog of war asset can raycast against (maybe the terrain has to be on a certain layer)? I'm just trying to guess though.


    Thanks again for any help or suggestions. Also, if we need to I could private message you.
     
  35. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    The only requirement for you terrain shader is that it writes to the depth buffer (which, if it's opaque, chances are it's fine).
    Some more tests you can try:
    • Add some other post processing effects to the same post processing profile to make sure it's picking up on the correct volume.
    • Check the Volume Mask on the camera is the same as the layer on your Volume game object.
    • Also check if you have any errors or warnings in the console.
    If this still doesn't work, it might be worth throwing everything in the sample scene into your current scene and, one by one, move things over to the way you want to use it. That way you can figure out which step breaks it.

    If you still can't get it to work, you can send me an email of your project (or a stripped down version if you want) and I'll try to debug it myself.
     
    Velo222 likes this.
  36. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    Unfortunately I still can't get the fog of war to show up for some reason. I'm working on stripping down my project so I can send it to you at some point. I'll also keep trying to get it to work. It's kind of a "weekend" project thing for now, but I'll keep working on it.

    What email address should I send it to? I could also use something like Dropbox if necessary. Thanks :)
     
    Last edited: May 15, 2020
  37. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    A stripped down version of your project is always the easier way for me to debug what's wrong :)
    You can find my email on the asset store page or at the bottom of the user guide.
     
    Velo222 likes this.
  38. pOgOstyle

    pOgOstyle

    Joined:
    Oct 13, 2016
    Posts:
    6
    Hello, i can't get the scripts get to work on Android. So far everthing works as expected in the editor.
    Anything i have to consider for the apk build ? Im working with 2019.3.7f with the legacyshader and mode. No Posteffects.
     
  39. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Are you getting compile errors, or is the fog not appearing?
     
  40. pOgOstyle

    pOgOstyle

    Joined:
    Oct 13, 2016
    Posts:
    6
    Game is running fine - including your demoRTS system. Just the fog doesn't appear.
     
  41. pOgOstyle

    pOgOstyle

    Joined:
    Oct 13, 2016
    Posts:
    6
    Even on a fresh unityproject i don't get any fog with your demoscene on Android 9 (S9).
     
  42. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    It sounds like you haven't included shaders into the Always Included Shader list. The steps to do this depends on whether you're using legacy/URP/HDRP. You can find the steps in the user guide in the setup section.
     
  43. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    Hello, what's the situation regarding URP/LWRP support?
     
  44. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Sorry for the wait.
    I am still trying to figure out how to implement custom PP in URP. Unfortunately, there still isn't enough information out that explains how to do it (or if it's possible at all). I'm hoping in the 2020.1 release unity will cough up some working examples and maybe even some propper documentation.

    I should point out that (apparently) the Post Processing Stack v2 is still supported on URP, although I haven't been able to get it to work.
     
    pixelR and faolad like this.
  45. adamcheong

    adamcheong

    Joined:
    Mar 30, 2020
    Posts:
    6
    Hi, I'm using this with RTS Engine and I wonder if there is a simple way to have permanent reveal for areas that have been explored.
     
  46. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    You're best bet is to setup up an invisible unit to keep that area clear. Alternatively, you can do this through code which might be slightly more performant:
    Code (CSharp):
    1. FoW.FogOfWarTeam.GetTeam(0).SetFog(bounds, (byte)0);
    Where bounds is the world space area of what you want to be unfogged.
     
  47. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    Hi, is there a solution already for 2019.3 or 2019.4 and URP?
     
    faolad likes this.
  48. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm still fighting with a few shader features with URP. I'm hoping it'll be ready soon... but I've said that before :(
     
    faolad likes this.
  49. jamesccc

    jamesccc

    Joined:
    Nov 17, 2012
    Posts:
    5
    Hi,
    Is there a way to control the fog strength (like transparency) but without affecting outside fog strength?

    I want the outside fog (border) solid black, but the fog in playzone be semi transparent
     
  50. gulpy3

    gulpy3

    Joined:
    Jun 3, 2014
    Posts:
    29
    Was working just fine for a while with HDRP then at some point during working on other features, fog is no longer appearing. Can I send you my scene or hop on discord to troubleshoot the issue?