Search Unity

Fog of War

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

  1. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, you are right! Thanks for pointing it out. If you send me an email (you can find it in the user guide), I can send you a unitypackage with the fix. If all goes well, I'll put out a patch for it.
     
  2. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    same fix for me? see previous post
     
  3. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Ah yes, sorry. If you email me too, I can give you the fix.
     
  4. Kaboom

    Kaboom

    Joined:
    Mar 16, 2014
    Posts:
    32
    It's 2018.2.16f1. I'll check if updating to 2018.2.20 helps.

    Update: nope, no change - still get the message, although everything appears to be working.
     
    Last edited: Dec 27, 2018
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    What's the road map for this asset? Can we expect optimization technique I have suggested before? What about custom fog shader creation? If this is already possible, which shader do I need to take a look at?
     
  6. RamonDevs

    RamonDevs

    Joined:
    Apr 11, 2015
    Posts:
    13
    Hey man. Been using this asset for a while. I had to create my own fix for the _CameraWS issue ("fix" , I just commented out a bunch of things).

    The SetFog(Bounds, byte) function never does 100% hiding in the fog. I'm doing byte with value of 1 or 255 or 100, never works. Do you happen to know how to make it work? Thank you.

    I inspect with Debug.Log on that area for Visibility and indeed the fog says something like "0.0295" instead of "1" which is fully fogged, but if I inspect via Debug.Log the "GetFogValue" at the same point, it says 255 or 1 or whatever value I input.

    I'm using 2D Physics, Plane XY.

    Thank you in advance and happy new year.
     
  7. AlexaStar

    AlexaStar

    Joined:
    Dec 28, 2015
    Posts:
    5
    Good question, I have a similar issue!

    Any help from someone here? :)
     
  8. RamonDevs

    RamonDevs

    Joined:
    Apr 11, 2015
    Posts:
    13
    Another comment: The comments on the code are wrong. It says it'll return "1" but it returns "255" in some places, and in others it says the opposite, to return the wrong thing too.
     
  9. Jwoozly

    Jwoozly

    Joined:
    Oct 7, 2018
    Posts:
    1

    When I downloaded the FogOfWar Asset, for some reason the IsInFog() method is not in the FogOfWar.cs and I'm getting errors.

    Do any of you have the code for IsInFog()?

    Thanks :)
     
  10. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    IsInFog() was a bit ambiguous because devs often have different interpretations on how much something should be fogged for something to be "in fog". There instead you can just use the GetFogValue method:
    byte GetFogValue(Vector3 position)
    This returns a byte where 0 is completely unfogged and 255 is fully fogged. So you can do something like this:
    Code (CSharp):
    1. FogOfWar.GetTeam(0).GetFogValue(transform.position) > 250
     
  11. Kaboom

    Kaboom

    Joined:
    Mar 16, 2014
    Posts:
    32
    Do you have a release planned for this fix? If not, I'd also like to receive the patch! I'll send you an email.
     
  12. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Sorry for the wait. I am intending to upload the fix for this in the next few days (it could take a few additional days for the asset store to approve it). But feel free to email me if you would like it sooner.
     
  13. RamonDevs

    RamonDevs

    Joined:
    Apr 11, 2015
    Posts:
    13
    @stu_pidd_cow I'll reask because you seem to have missed my issue:

    Hey man. Been using this asset for a while. I had to create my own fix for the _CameraWS issue ("fix" , I just commented out a bunch of things).

    The SetFog(Bounds, byte) function never does 100% hiding in the fog. I'm doing byte with value of 1 or 255 or 100, never works. Do you happen to know how to make it work? Thank you.

    I inspect with Debug.Log on that area for Visibility and indeed the fog says something like "0.0295" instead of "1" which is fully fogged, but if I inspect via Debug.Log the "GetFogValue" at the same point, it says 255 or 1 or whatever value I input.

    I'm using 2D Physics, Plane XY.

    Thank you in advance and happy new year.
     
  14. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Sorry, I'm not sure how I missed your message, but I'm glad you managed to fix the issue on your own.

    SetFog() will set the fog to whatever you want it to, where 0 is not fogged and 255 is fully fogged (you are correct that there is an error in the comments, I will fix this up). What I think what you are seeing is that the fog clears that space, but is then immediately returned to a "partially fogged" state. You can adjust what the partial fog amount is with the Partial Fog Amount slider on the FogOfWar component.
    If you want to have it continuously at fully unfogged, you will need to spawn a unit at that spot with the FogOfWarUnit set up the way you want it.

    This is probably happening because you are checking on the same frame that you set it. I think if you check the next frame (or after the next fog frame, which may be longer than a single unity frame), then you will see what the final display value is.

    Sorry again for not responding to your original query :confused:
     
  15. Fdudka

    Fdudka

    Joined:
    Jul 27, 2015
    Posts:
    16
    Hi, I'm getting a HUGE spike or garbage collector. My games runs at 100-200 fps but every... 10 seconds Fog of War is making the game "freeze" due to the GC getting clean.

    any suggestions?
     
  16. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    When I profile it, it tells me that there are 0 bytes allocated every frame (except for setup). Does a deep profile tell you what the source is?
     
  17. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    Where are we getting the Lightweight Render Pipeline update?
     
  18. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Super soon! I have it working right now but I'm dissatisfied with the design currently, so I'm doing some final tweaks. It should be in the next release, but I'm not super sure when that'll be.
     
    Moonei and faolad like this.
  19. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Is it going to be a optional change? I really do not like LW or HD rendering pipelines quite yet. So Id personally like to not be forced to use it.
     
  20. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    It will be optional. That's kinda been the frustrating part of designing this...
     
    Paul-Swanson likes this.
  21. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Hi,
    Is the fog of war server authoritative ?
    Could you make a webGL demo please?
     
  22. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I haven't looked at the demo in a while. I'll try to get a webGL version up ASAP.
     
  23. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have just uploaded FogOfWar 1.17 to the asset store! (it may take a few days for unity to approve)

    This is a pretty big update and will break backwards compatibility in order to support HDRP and LWRP as well as the legacy render pipeline. This also does not support HDRP for Unity 2019.1, as unity hasn't made a way to make custom post processing effects with the new volume system. So if you are on HDRP, I'd recommended waiting for 2019.2 which I will be adding support for.

    Some migrating will be required for this if you are coming from an older version. If so, check out the migration section in the user guide.

    Release notes aren't long for this one, but it's been a lot of work behind the scenes!
    • Added support for Postprocessing Stack v2!
    • Split FogOfWarTeam from visual side to make new post processing tech easier to migrate to
    • Better multi-camera support
    • Optimised clear fog
    • Improved sample scenes to work across multiple render pipelines
     
    Brogan89 likes this.
  24. MarsDc

    MarsDc

    Joined:
    Mar 19, 2018
    Posts:
    3
    It doesn't work after the build, but it works in the editor.
    Everything works fine in the editor, but after building, I can't see the fog. I can get the correct value with GetFogValue, the display and hiding of the object also works, but I can't see the fog after the build.
    It's same in Samples Scene. I have tried both Unity 2018.3.1f1 and Unity2018.3.6f1.
    What should I do?:confused:
     
  25. MarsDc

    MarsDc

    Joined:
    Mar 19, 2018
    Posts:
    3
    I checked the "output_log.txt".
    ArgumentNullException: Value cannot be null.
    Parameter name: shader
    at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
    at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00007] in <9b3b6573bfb64614aa7ee01c0905dc79>:0
    at FoW.FogOfWarLegacyManager..ctor () [0x00011] in <fde3b04daf1c4a4bb11edb8c5efe2ae1>:0
    at FoW.FogOfWarLegacy.Awake () [0x00000] in <fde3b04daf1c4a4bb11edb8c5efe2ae1>:0
     
  26. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have a fix for this. If you really need it asap, email me and I'll give you the fix. I am in the process of uploading a hotfix to the asset store.
     
  27. MarsDc

    MarsDc

    Joined:
    Mar 19, 2018
    Posts:
    3
    Thx, I have solved this problem.
     
  28. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello,

    I read through the documentation must have missed this - does this asset support opacity for the fog of war? I.e., semi-transparent fog instead of complete blocking.

    Thanks.
     
  29. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, this is supported. Changing the alpha value on the fog color will produce this effect.
     
    tapawafo likes this.
  30. SiliconAvatar

    SiliconAvatar

    Joined:
    Mar 23, 2014
    Posts:
    50
    I'm getting a "flickering" effect where the tile that has the collider on it briefly shades while the character is moving from one tile to another.

    This even happens in the demo 2D legacy scene so it's not my project as far as I know.

    Go to the far left top corner of the demo map. Move left and right. The left wall briefly shadows in and out while the character is moving even though it never loses line of site. It happens in scene view play mode or a build.

    Anti flicker doesn't resolve it. It makes the scene look like it's got some kind of underwater shadow effect during movement.
     
  31. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yeah, that definitely shouldn't happen. I'll get onto fixing it. Thanks for pointing this out.
     
    SiliconAvatar likes this.
  32. SiliconAvatar

    SiliconAvatar

    Joined:
    Mar 23, 2014
    Posts:
    50
    Thanks for looking into it!
     
  33. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have a fix for this. If you need it now, feel free to email me.
     
    SiliconAvatar likes this.
  34. SiliconAvatar

    SiliconAvatar

    Joined:
    Mar 23, 2014
    Posts:
    50
    Thanks - I sent you an email.
     
  35. FredTuna

    FredTuna

    Joined:
    Dec 28, 2016
    Posts:
    16
    Hi, this looks like a great asset. I was wondering if support for HDRP in 2019.1 is planned?
     
  36. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    The HDRP's new post processing system doesn't support custom shaders in 2019.1, which is what FoW is built on. Unity has said that 2019.2 will add custom shader support for HDRP, so I will work to implement it as soon as I can.
    Unfortunately, there isn't much else I can do on my end.
     
  37. unknown17771

    unknown17771

    Joined:
    Nov 12, 2016
    Posts:
    19
    Can i get FogOfWarTestGUI.cs ? I cannot find in the package that i downloaded. I nedd it for mini map. Thanks
     
  38. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    The test GUI was removed due to some of the features being incompatible with unity 2019.1, but I am currently working on a new version that demonstrates how to make a minimap. I have attached the old version if you still want to reference it (most of the FogOfWar side of things are still the same). If you need help with anything, don't hesitate to send me an email!
     

    Attached Files:

  39. Sorn

    Sorn

    Joined:
    Jul 17, 2013
    Posts:
    14
    Are there any videos of this in use?
    Would like to see real-time end results if possible.
     
  40. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I believe both of these videos use FoW:



    You don't see the fog a whole lot in these, so they might not be the best demonstration.
     
  41. Sorn

    Sorn

    Joined:
    Jul 17, 2013
    Posts:
    14
    Yeah, wondering how it works with multiple meshes in a tight area.
     
  42. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    What do you mean by "multiple meshes"?
     
  43. Sorn

    Sorn

    Joined:
    Jul 17, 2013
    Posts:
    14
    My bad, I assumed you were using some sort of per-object strategy for this, but I was definitely wrong.
    Bought your asset and I'm very impressed, does everything I needed!

    As an aside, I'm forced to use Legacy right now because I'm using https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/outline-effect-78608 which won't support the PPS. Do you know of a package like this that would work with the PPS? :)
     
  44. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Glad it's working for you!

    As for the outline shader, you can always try this (I haven't tried it): https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/pro-outline-136956

    You could also try implementing it yourself (it's not too complicated if you know the basics of shaders): https://www.videopoetics.com/tutorials/pixel-perfect-outline-shaders-unity/

    Don't know if I can help you much more unfortunately :(
     
    Sorn likes this.
  45. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi, I have two questions.

    #1: Is this asset a post-process effect, or something I have to add to every single one of my shaders/materials? I'm working on a game with lots of units/characters, so if I have to add this to all of my character's shaders that will be a big task.

    #2: Is there a guesstimation on when it might be ready for Unity 2019.2? I read you were planning on working on it, just wanted to make sure.

    Thanks.
     
  46. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, it uses post processing. There are no other requirements for other shaders that you have in the scene.

    FoW should work fine in 2019.2, except for HDRP. HDRP will be coming in the next FoW release (I suspect it'll be in the next few weeks or so).
     
  47. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Oh that sounds great. Thank you :)
     
  48. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Unfortunately, it seems like unity still hasn't provided an official API for HDRP post processing in 2019.2, so this will have to wait until 2019.3 (which I suspect will be around November:confused:). Sorry to all the HDRP users holding out for this. I will definitely jump onto this as soon as unity releases the API.
     
  49. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Oh sad to hear that :( Yes, I was kind of hoping for it soon. But I am glad you plan on trying to do it when it's possible. HDRP is still hard to work with in a lot of areas, so I know the feeling. Thank you for the information and for keeping us updated.
     
  50. unity_ppZWTHsqCWojkA

    unity_ppZWTHsqCWojkA

    Joined:
    Aug 26, 2019
    Posts:
    2
    Hi, I downloaded the version 1.18, however it seems no sample of LWRP, only post process sample? Do you have any tips for the FOW effect rewriting in LWRP? Thx