Search Unity

Fog of War

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

  1. KD_Zugalu

    KD_Zugalu

    Joined:
    Jan 3, 2020
    Posts:
    6
    We got it fixed, we had to remove ambient occlusion from the Render Data
     
  2. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
  3. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
  4. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    601
    I'm making a turn based game so I wanted to use Manual Update so the fog would only be updated when I move a unit and at the start but I only get a pitch black scenario if I disable Update Units and Update Automatically. Pressing the Manual Update button or calling the method by code does nothing.

    Am I missing something? I thought that was the point of ManualUpdate but the code description says "This should only be called when updateAutomatically is true" which seems to contradict the documentation.
     
  5. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, you're right! The comment in the code is wrong. I'll fix that up.
    As for your issue, the Manual Update should be working as you describe. You should see something happen if you do the following:
    1. Set updateAutomatically to false
    2. Move a unit to a new location
    3. Call ManualUpdate()
    Calling ManualUpdate() every frame may do some weird things. In this case, you should just enable updateAutomatically over the frames you want the fog to update.
     
  6. Atharol

    Atharol

    Joined:
    Feb 20, 2019
    Posts:
    4
    Hello everyone, I'm using the RTS Engine and I managed to get this Fog of War system to work,
    But how do I fix/add the second layer of fog?

    Just to explain what I mean with the second layer of fog,
    The first layer is the Hard fog that covers the entire map until discovered. (Including terrain)
    The second layer of fog "light fog" is what shows cliffs, mountains rivers but hides enemy units if they are not within your vision range.

    Also sorry for being a noobie here, I've read the entire documentation (30 pages) without getting any smarter :rolleyes:
     
  7. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm not super familiar with the RTS Engine implementation, but I'm guessing you're referring to partial fog. It will be on the FogOfWar renderer (which depends on whether you're using URP, HDRP, legacy, PPSv2). If you set that all the way down/up it should remove it.
     
  8. XCet

    XCet

    Joined:
    Jul 12, 2020
    Posts:
    2
    Hey everyone. Sorry if this is an obvious question, but I have trouble letting units disappear in the partial fog. (The fog that is there after an area has been seen) I have played around with the Partial Fog Amount and HideInFog, but it seems like the Fog Strength does not differ between a visible area and an area in partial fog.

    EDIT: I use legacy render pipeline
     
    Last edited: Oct 7, 2021
  9. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    The HideInFog script should do this for you. The Partial Fog Amount on the HideInFog script is related to the Partial Fog Amount on the FogOfWarTeam component. So they shoulld be set pretty close to the same. If it's set all the way to 0 or 1 on the FogOfWarTeam component, it may do some weird things.

    Also, make sure that the HideInFog component is pointing to the correct team (the team ID should be the same as the FogOfWarTeam component).
     
    XCet likes this.
  10. XCet

    XCet

    Joined:
    Jul 12, 2020
    Posts:
    2
    Ah, thank you. My issue was that I used the team the unit belongs to instead of the team of the player that should not be able to see it.
     
  11. bananapowerz

    bananapowerz

    Joined:
    Dec 31, 2016
    Posts:
    3
    I bought this plugin today and it was really good plugin. thx.
    But 2d mobile legacy and urp seems not working on android(didnt test on ios, and editor and pc are woking)...
    Is it supposed to be not working(2d mobile legacy and urp) on android?
    thx
     
  12. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I've fixed a few bugs related to this but they haven't been released to the asset store yet. Send me an email (you can find it at the very bottom of the user guide) and I'll send you a unitypackage that should fix it.
     
    bananapowerz likes this.
  13. bananapowerz

    bananapowerz

    Joined:
    Dec 31, 2016
    Posts:
    3
    ty:) I sent an email.
     
  14. Asledziu

    Asledziu

    Joined:
    Oct 8, 2019
    Posts:
    5
    Hey
    I want to implement fog of war to rts engine, but I converted the project to HDRP and not everything works as if I would like and need help

    https://assetstore.unity.com/packages/templates/packs/rts-engine-79732

    1 as long as characters, buildings, resources work in the right way (i.e. they disappear and appear depending on when we get closer or further away),
    upload_2021-10-26_20-42-49.png


    2 but I have a problem with the fog, it is completely silent, these are the FOG settings of the manager, camera and other objects
    upload_2021-10-26_20-47-52.png
    upload_2021-10-26_20-49-18.png

    upload_2021-10-26_20-49-55.png

    let me know if you can help, if you need more information or maybe you need to share a project.
    regards
     
  15. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    For HDRP you won't need the FogOfWarLegacy script in the scene. Instead you will need to add a Volume with the FogOfWarHDRP effect on it. Also, to test you might want to remove the Fog Color Texture and disable blurring as that may make it harder to see. Everything else you have seems correct.
     
  16. Asledziu

    Asledziu

    Joined:
    Oct 8, 2019
    Posts:
    5
    Hey
    im add Box volume with that Fog of war HDRP


    upload_2021-10-27_1-39-45.png

    when I removed the Fog of War legacy from the minimap camera and camera
    but then the project has stopped working properly
    upload_2021-10-27_1-46-32.png

    I finally removed the HDRP manager because it actually requires legacy scripts, but that didn't fix the problem either
    upload_2021-10-27_2-5-39.png
    upload_2021-10-27_2-3-0.png
    upload_2021-10-27_2-8-48.png
    I hope I haven't broken it
     
  17. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm not 100% sure because I'm not sure what RTSEngine is doing under the hood for HDRP. You may need to speak with the RTSEngine dev about that error message. Or maybe check if there's a HDRP version of the FogOfWarRTSManager script.
    But I can say for sure that you won't need the FogOfWarLegacy script if you are using HDRP.
     
    Asledziu likes this.
  18. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    I am using Unity 2017.4.37 and I have bought your product. Can I just have a shader, in which you add to an object and it will display the render texture of explored continuosly? Your product crashes in legacy mode that is why. let me check your email
     
  19. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Hi stu_pidd_cow, mind giving me an older build, that is with Unity 2017.4.37f1.You can see how it crashes all the time. You know my email, I have conta
    cted you.
     

    Attached Files:

  20. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I've sent you an email.
     
  21. Asledziu

    Asledziu

    Joined:
    Oct 8, 2019
    Posts:
    5
    Hi,
    I wrote to people from RTS engine but they probably already work on version 2 and they answer questions less often, so I bit into the documentation myself and managed to make some progress, but I have a different problem, can you help me with it?
    this is view from game upload_2021-11-3_11-37-19.png
    but on scene i see fog is working
    upload_2021-11-3_11-37-55.png
    that is my main camera settings

    upload_2021-11-3_11-39-12.png
     

    Attached Files:

  22. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    What happens if you remove the FogOfWarClearFog script? Does it look correct then?
     
    Asledziu likes this.
  23. Asledziu

    Asledziu

    Joined:
    Oct 8, 2019
    Posts:
    5
    hey, removing this script didn't fix the problem, but it did improve fps
    but I immediately checked again how the camera is made here and I was surprised that there is a camera script in both the camera and the cameraUI, after removing the camera script of this from cameraUI
    suddenly it started to work
    I do not know why it was there, the basic skeleton of the map is generated automatically from the RTS engine (I am writing this for people who may have a similar problem and level of experience)
    upload_2021-11-4_10-17-12.png upload_2021-11-4_10-18-30.png

    thanks for helping me
     
    stu_pidd_cow likes this.
  24. Harjawalda

    Harjawalda

    Joined:
    Sep 1, 2018
    Posts:
    15
    Hi, I have an issue with my FOW Setup in a interior tunnel level, were there is no terrain beneath it. I have set up the cave walls as a line of sight mask with 0 penetration that prevents the "void" to be revealed, but when I reveal more areas I get holes in the background that grow along with it. When I rotate the camera, this empty area rotates with it like it is a projection of the revealed area. Since I'm using 2019.3 I cannot upgdrade btw.
     

    Attached Files:

  25. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    It's a bit hard to tell what's going on. It looks like the projection your seeing is perhaps the fog being displayed on the far plane (there is a toggle on the FogOfWar renderer called "Fog Far Plane" which should turn this on/off).
    But it sounds like the real issue is that the line of sight is leaking through the geometry? I don't suppose you could send a video of the issue?
     
  26. RUzi187

    RUzi187

    Joined:
    Sep 6, 2019
    Posts:
    3
    Hey is it possible to set this up with URP camera stacking? I need to show fog of war over one of the overlay cameras.
    Base.png City.png Fow.png
     
  27. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    You can. The Clear Fog script will do do exactly that, but you may get more flexibility by setting it up yourself.
    If you want to set it up yourself, then you won't need that Main Camera (in your second screenshot).
     
  28. RUzi187

    RUzi187

    Joined:
    Sep 6, 2019
    Posts:
    3
    I'm unable to get it working with the setup I showed you. Maybe I am missing a setting or something?
     
  29. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I've replied to your email.
     
  30. airop

    airop

    Joined:
    Sep 4, 2012
    Posts:
    34
    We cant seem to get this to work. other post processing effects do load but the fog of war just does not show in our build. we are using unity 2021.2.7
     
  31. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm working on a fix for this, but it hasn't been released yet. Feel free to email me (you can find it at the bottom of the user guide) and I'll send you a unity package with the fix.
     
  32. lszmarossi

    lszmarossi

    Joined:
    Nov 21, 2018
    Posts:
    1
    Doesn't work at all. Followed the user guide to a teeth but there's no fog at all, even after plugging it in URP Volume and checking the URP settings, don't know what to do with this
     
  33. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Yes, there appears to be an issue in the latest URP version. It should be fixable by going to your UniversalRenderData asset and setting Intermediate Texture to Always. I've found that there can be some other issues. I'm looking into these and will get a new update out as soon as possible.
     
  34. usaidpro

    usaidpro

    Joined:
    Feb 14, 2018
    Posts:
    13
    I'm having issues as well getting FogOfWar to show with the latest URP using the volume system. I am using Unity 2021.2.8f1 with URP version 12.1.3 and Fog Of War version 1.24. I have been replicating the User Guide setup for URP for several hours with no fog of war showing. However, I am able to see post-processing effects such as Viginette affecting my camera when added to my global volume, so the volume itself is properly working.

    I have tried setting Intermediate Texture to Always, it did not work. I have verified the URP shader is being used and the FogOfWarTeam is placed correctly. Is there an estimated date range when an update with potential fixes will be deployed?
     
  35. PixelLifetime

    PixelLifetime

    Joined:
    Mar 30, 2017
    Posts:
    90
    Hi, did you have a problem with shaders in WebGL build? For me it works just fine in editor and in Windows build but in WebGL build it seems like a shader is missing, basically fog is magenta(pink) and everything is magenta(pink).

    1. I have rebuilt without fog, it works fine.
    2. Checked shader variants, always included, added all of the available ones from FoW.
     
  36. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I'm getting reports of different issues from different people. But most seem to be saying that it's pretty busted. I've narrowed the issue down to a change in the latest URP. I've submitted a bug report (I have another thread about it here if you're interested). Unfortunately, there's not much more I can do until I get a reply from Unity.

    In the meantime, I'd recommend downgrading URP to a previous version (I believe this will also require you to downgrade Unity to before 2021.2 too).
     
  37. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    What render pipeline and Unity version are you using?
     
  38. farrenzo47

    farrenzo47

    Joined:
    Jun 22, 2016
    Posts:
    2
    Hi there - I'm running into an issue where HDR colors are not enabled when I've turned on the FogOfWar URP feature. I'm sure I'm missing something straightforward, but the only difference is toggling the FOW URP feature in my post process volume. (I've also checked the docs but haven't found anything)

    I've included screenshots showing what the eye color looks like with FOW enabled/disabled.

    I'm using Unity v 2020.3.25f1, FOW v1.24.0, and URP v10.7.0.

    Thanks, and let me know if you need more info!
     

    Attached Files:

  39. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I have a fix for this that will go out in the next release. You can fix it yourself by replacing line 66 in FogOfWarURPPass.cs with this:
    Code (CSharp):
    1. _cmd.GetTemporaryRT(destination, _renderingData.cameraData.camera.scaledPixelWidth, _renderingData.cameraData.camera.scaledPixelHeight, 0, FilterMode.Point, _renderingData.cameraData.isHdrEnabled ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
    Or you can send me an email and I'll send you an updated unity package.
     
    farrenzo47 likes this.
  40. jmattarock_unity

    jmattarock_unity

    Joined:
    Mar 10, 2018
    Posts:
    25
    Is there away to hide a unit in the Partial Fog? seems if its anything higher then .1 the unit will stay visable. Trying to have 2 levels of fog and still hide some stuff behind the partial fog.
     
  41. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    When using the HideInFog script, you will have a slider there call minFogStrength that will control the threshold. The HideInFog script is made to be an example script. It's pretty basic, so feel free to jump in and modify it. Let me know if you need any help with it.
     
  42. farrenzo47

    farrenzo47

    Joined:
    Jun 22, 2016
    Posts:
    2
    Thank you! That worked like a charm!
     
    stu_pidd_cow likes this.
  43. PixelLifetime

    PixelLifetime

    Joined:
    Mar 30, 2017
    Posts:
    90
    • URP
    • Unity 2021.1.10f1
     
  44. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I just tried myself and found that I hadn't built with the URP scenes. Instead, I was building with legacy which caused this to happen. After fixing that, it worked fine in 2021.1.16f1:


    If this isn't the case for you, could you send me an email (you can find it in the user guide) with a zip of the project. I will try to debug the issue with that.
     
  45. endseeker2

    endseeker2

    Joined:
    May 19, 2021
    Posts:
    2
    does this lib handle transparent objects well? since its a full screen pass... thank you very much!
     
  46. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Because fog of war is implemented as a post process, transparency can cause issues. There are ways around it, such as using dithering with a cutout shader, or forcing the transparent shader to write to the depth buffer. Neither are ideal.
    Alternatively, you can write your own shaders that tap into the fog data. The downside to this is that you must modify all off you transparent shaders for this to work.
     
    endseeker2 likes this.
  47. siolyol

    siolyol

    Joined:
    Jul 12, 2017
    Posts:
    1
    Hello
    Somebody know if this Fog of War works with webGL and Linux platforms?
     
  48. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    I've only tested webGL with windows. I'm happy to help you through any issues if you run into trouble with it.
     
  49. Dumpling007

    Dumpling007

    Joined:
    Dec 13, 2018
    Posts:
    32
    I added the component following the help instructions,I use cinemachine camera and now the whole scene is dark?I want the player is surrounded by light;
    You can see the following image:
     

    Attached Files:

  50. stu_pidd_cow

    stu_pidd_cow

    Joined:
    Aug 4, 2014
    Posts:
    233
    Some questions to help diagnose the issue:
    1. What version of unity are you using?
    2. What render pipeline are you using?
    3. Is this only in a build or in the editor?
    4. Are the provided sample scenes working correctly?