Author Topic: Tasharen Fog of War  (Read 145054 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #165 on: December 26, 2015, 09:40:39 PM »
It's not 2-3 lines, more like ~12 across both shader and C# code. As for how long it would take, that would vary on your skill level so can't say for sure.

hannahwills

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Tasharen Fog of War
« Reply #166 on: December 27, 2015, 04:48:14 AM »
Hi Aren,

Thanks so much for making such a great plugin! I know this question is very specific to my scene, but I have multiple floors that are stacked on top of each other, and when a revealer is on an inner floor it seems as if there aren't any nodes on that floor. I'm guessing this is because the FOW system is set up to only make one node in the heightmap per xz point, and it's colliding with something above or below it already, but I was wondering if there was a way to make layered floors work within the system. Each floor is exactly 10 units high.

Thanks again!



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #167 on: December 27, 2015, 05:22:53 PM »
By default the FOWSystem class uses Physics.SphereCast / Physics.Racast to determine if something is visible or not. This happens in FOWSystem.CreateGrid() function. Inside it all it does is creates the 2D heightmap using the sampled height values. This heightmap is then used in the FOW thread to determine visibility.

You can create a custom FOW class by deriving from FOWSystem and overwriting the CreateGrid() function. When switching from XZ 3D to XY 2D, you will want to do this and alter usage of 'z' to be 'y' inside that function.

hannahwills

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Tasharen Fog of War
« Reply #168 on: January 02, 2016, 07:20:48 PM »
Thanks for getting back to me! I'm not sure I asked my question correctly, but I'm not trying to switch to an XY 2D, I want to keep the XZ plane but have multiple stacked height points. So for example, if I'm standing in a room, I'd like to not see the room below me as well as the other rooms on the same floor. With the 2D heightmap the rooms around me get blocked but not the ones above or below, even when I have the raycasting set to collide with the floor layers.

Thanks again!




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #169 on: January 04, 2016, 05:38:35 AM »
I would suggest you not show the bottom floor while you're on the 2nd floor, or at least block it somehow. The way the system works is it's flat basically. The height changes are done on a "if above Y, it's visible". There is no "if above Y and below Z" type checks because heightmaps only have one value -- each point's height.

hannahwills

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Tasharen Fog of War
« Reply #170 on: January 04, 2016, 03:58:13 PM »
That makes sense, thanks!

zmeinaz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Tasharen Fog of War
« Reply #171 on: February 28, 2016, 12:52:14 PM »
Hello,

I am using FOW on the x-y plane with the shader method and my maps are taller than they are wide (150x350). Is it possible to adapt FOW to rectangular world sizes and texture sizes? I tried updating fowSystem but the revealed area is warped and the indices are off. For example, using the radius revealer, the revealed area is an oval that is wider than it is tall. I am trying to get a world size and texture size such that one pixel in the texture equals one unit on my map.

The idea is to avoid processing an extra 70,000 pixels of the texture that are unused in order to improve performance on low end devices.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #172 on: March 01, 2016, 06:35:20 AM »
If you're passing a rectangular texture to the shader, you will need to adjust the FOW shader to support a rectangular shape by basically stretching it / squishing the UVs in the shader as needed. Unfortunately I can't suggest anything specific...

zmeinaz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Tasharen Fog of War
« Reply #173 on: March 01, 2016, 07:45:24 AM »
I see what you mean... Is it possible to optimize the UpdateTexture function in FOWSystem.cs to only update indices that were changed since the previous update?

The reason I am looking into this sort of optimization is because I was originally using a world and texture size of 512, but I saw large performance spikes on older devices (iPad 3). Reducing to a size of 350 helps a lot, but I think it will still impact even older devices (iPad 1).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #174 on: March 06, 2016, 01:18:04 PM »
Everything is possible, sure... but as I mentioned I can't suggest anything specific. Size 512 is indeed pretty big -- that's a 1 MB texture you're updating. In Windward I believe I use 256x256 if not 128x128. Fog of war is supposed to be pretty blurry anyway, there is little reason for that much precision.

hiramtan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Tasharen Fog of War
« Reply #175 on: February 14, 2017, 02:40:18 AM »
Please check fog of war on unity version 5.5.0f3, it's works on unity5.3.4, but when I upgrade unity to 5.5.0, it's no longer work anymore...really hope can fix this issue, Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War
« Reply #176 on: February 18, 2017, 08:08:24 PM »
The fog of war package has been deprecated a long time ago now...

hiramtan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Tasharen Fog of War
« Reply #177 on: February 20, 2017, 09:45:10 PM »
I have modified shader to let it work on version 5.5.0,Thank you all the same.

Velo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 13
    • View Profile
Re: Tasharen Fog of War
« Reply #178 on: June 11, 2017, 06:42:23 PM »
Hiramtan, when you modified the shader for 5.5.0, does the "Image Effect" fog of war work as well?  I'm really trying to get the Image Effect part of the asset to work again in Unity version 5.5 and beyond.  If so, would you mind sharing what you did to modify the shader?

And ArenMook, if you see this, I know the asset has been deprecated for a long time now, and you're not actively supporting it anymore, but is there any chance you could help me get the Image Effect to work again in 5.5+ (it almost works actually, I feel it just needs a small adjustment somewhere in either the shader or the c# script).  I'm also willing to pay you for it, so contact me if you're interested.

Thanks.

Velo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 13
    • View Profile
Re: Tasharen Fog of War
« Reply #179 on: June 11, 2017, 11:00:15 PM »
Ok I figured out how to get the fog of war "Image Effect" to work again with Unity 5.5 (and perhaps higher versions as well).   :D

For anyone else that might want to know, Unity basically switched (inverted) the Zbuffer value around as of Unity 5.5.  So, what I had to do was in the Fog of War shader put in a line of code that is essentially:  "depth = 1 - depth" in the part of the shader that contains the definition for the depth variable.  This modifies the value to align with the change that Unity made regarding the Zbuffer.

So it works now, and I'm very happy about that.