Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

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:
    94
    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:
    117
    same fix for me? see previous post
     
  3. stu_pidd_cow

    stu_pidd_cow

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

    Kaboom

    Joined:
    Mar 16, 2014
    Posts:
    28
    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:
    1,389
    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:
    9
    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:
    1
    Good question, I have a similar issue!

    Any help from someone here? :)
     
  8. RamonDevs

    RamonDevs

    Joined:
    Apr 11, 2015
    Posts:
    9
    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. ianhunter373

    ianhunter373

    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:
    94
    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:
    28
    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:
    94
    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:
    9
    @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:
    94
    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:
    15
    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:
    94
    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:
    25
    Where are we getting the Lightweight Render Pipeline update?
     
  18. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    94
    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:
    224
    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:
    94
    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:
    423
    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:
    94
    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:
    94
    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:
    94
    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. matteumayo

    matteumayo

    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:
    94
    Yes, this is supported. Changing the alpha value on the fog color will produce this effect.
     
    matteumayo likes this.
  30. lostdragon

    lostdragon

    Joined:
    Mar 23, 2014
    Posts:
    48
    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:
    94
    Yeah, that definitely shouldn't happen. I'll get onto fixing it. Thanks for pointing this out.
     
    lostdragon likes this.
  32. lostdragon

    lostdragon

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

    stu_pidd_cow

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

    lostdragon

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

    FredTuna

    Joined:
    Dec 28, 2016
    Posts:
    2
    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:
    94
    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. mybreeze

    mybreeze

    Joined:
    Nov 12, 2016
    Posts:
    14
    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:
    94
    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: