Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - garside

Pages: [1]
1
Other Packages / Re: Fog of War Thread Error
« on: March 06, 2015, 04:13:10 AM »
No rush or worries! More just an FYI than an open issue for me. :)

Have a nice time!

2
Other Packages / Re: Fog of War Thread Error
« on: March 03, 2015, 06:43:49 PM »
Sorry that's probably from my modifications.

Here's my copy of the file.

  1.  
  2. 699                                             if (dist < minRange || (cx == x && cy == y))
  3. 700                                             {
  4. 701                                                     r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;
  5. 702                                             }
  6.  
  7.  

3
Other Packages / Re: Fog of War Thread Error
« on: March 03, 2015, 03:30:04 PM »
Okay so while working on it today, whatever causes it to happen fired, and it tripped up my warning logger. Here's the stack trace of the error which would have otherwise killed the FOWSystem:

  1. FOWThreadException: System.IndexOutOfRangeException: Array index is out of range.
  2.   at FOWSystem.RevealIntoCache (.Revealer r, Single worldToTex) [0x001eb] in C:\Users\Eric\Code\ConjurersQuest\Assets\Scripts\Vendor\FogOfWar\FOWSystem.cs:701
  3.   at FOWSystem.RevealUsingCache (.Revealer r, Single worldToTex) [0x0000b] in C:\Users\Eric\Code\ConjurersQuest\Assets\Scripts\Vendor\FogOfWar\FOWSystem.cs:624
  4.   at FOWSystem.UpdateBuffer () [0x001dd] in C:\Users\Eric\Code\ConjurersQuest\Assets\Scripts\Vendor\FogOfWar\FOWSystem.cs:493
  5.   at FOWSystem.ThreadUpdate () [0x00023] in C:\Users\Eric\Code\ConjurersQuest\Assets\Scripts\Vendor\FogOfWar\FOWSystem.cs:312
  6.  

4
Other Packages / Re: Fog of War Thread Error
« on: March 03, 2015, 07:44:18 AM »
Sorry I didn't write it down. I can probably reproduce it easily enough?

I was looking through the code and saw that it was adding itself with locking the array so I didn't think that was going to be the problem.

It was something to do with r.cachedBuffer being uninitialized or something IIRC?

The error was transient and hard to reproduce.

Basically, there was some underlying condition (maybe a race condition given the threading?) which after instantiating a gameobject with a FOWRevelaer on it, there was like a 10% chance the entire FOW system would stop responding.

After unsuccessfully poking around other parts of the code, I managed to get narrow it down to an error happening in that UpdateBuffer() call.

I think the cacheBuffer was uninitialized in the RevealIntoCache method. However, this was a temporary thing (which is why I thought race condition), as simply not breaking on the error causes smooth operation once the error gets swallowed.

I just tried for a bit to reproduce it but of course was unable. I had the stack trace in a text file on my notepad but I moved my computer since then and had closed it absentmindedly. :|

5
Other Packages / Re: Fog of War: Custom shaders in editor mode
« on: February 26, 2015, 09:06:07 AM »
So I took a look but all the shaders seemed to already have white or clear as their default color. My knowledge of shaders is super limited, so I decided to try a different avenue and came up with some success.

Instead of addressing the shader code at all (cause I implemented like dozens of shaders to use the FOW system), I added a small utility to fix the issue.

There's likely a better way to handle it, but I'm not very experienced writing editor scripts either. For now, I just created a new game object, put it as a child of the FOWSystem, tagged it as EditorOnly, and threw the following component on it:

  1. [ExecuteInEditMode]
  2. public class FOWEditor : MonoBehaviour
  3. {
  4.         void Update ()
  5.         {
  6.                 if (!Application.isPlaying)
  7.                 {
  8.                         Shader.SetGlobalColor("_FOWUnexplored", Color.white);
  9.                         Shader.SetGlobalColor("_FOWExplored", Color.white);
  10.                         return;
  11.                 }
  12.         }
  13. }
  14.  

Edit:

I had modified the FOWSystem directly to do this originally, but it made the console whine about the textures being unused all the time, so I moved it to a separate utility to quiet the console.

6
Other Packages / Fog of War Thread Error
« on: February 26, 2015, 08:51:59 AM »
So using the FoW system, I ran into an issue where instantiating new prefabs with revealers on them would sometimes cause the entire FoW system to break and stop responding.

I managed to trace the issue down to a buffer not having the proper data at the time of updating which caused an error which silently killed the thread.

In the FOWSystem.cs file I made the following changes which seem to have made it resilient to this problem. The try/catch allows the thread to keep working when the instantiating buffer problem happens, and it seems to have kept things alive for me? Posting it here in case anyone else has this issue!

Note, the "Thread is alive" check in the late update function is a last-ditch effort to restart the system if it dies for another reason. It wasn't ever fired once the try/catch was put in the ThreadUpdate method.

  1. @@ -284,6 +284,13 @@ void LateUpdate ()
  2.                 Shader.SetGlobalVector("_FOWParams", p);
  3.                 Shader.SetGlobalTexture("_FOWTex0", mTexture0);
  4.                 Shader.SetGlobalTexture("_FOWTex1", mTexture1);
  5.  
  6.                 if (!mThread.IsAlive)
  7.                 {
  8.                         Debug.LogError("FOWThread Dead; Restarting");
  9.                         mThread = new Thread(ThreadUpdate);
  10.                         mThread.Start();
  11.                 }      
  12.         }
  13.  
  14.         /// <summary>
  15. @@ -300,7 +307,14 @@ void ThreadUpdate ()
  16.                         {
  17.                                 sw.Reset();
  18.                                 sw.Start();
  19.                                 UpdateBuffer();
  20.                                 try
  21.                                 {
  22.                                         UpdateBuffer();
  23.                                 }
  24.                                 catch (System.Exception e)
  25.                                 {
  26.                                         Debug.LogWarning("FOWThreadException: " + e.ToString());
  27.                                 }
  28.                                 sw.Stop();
  29.                                 if (debug) Debug.Log(sw.ElapsedMilliseconds);
  30.                                 mElapsed = 0.001f * (float)sw.ElapsedMilliseconds;
  31.  

7
Other Packages / Fog of War: Custom shaders in editor mode
« on: February 19, 2015, 01:58:48 PM »
So I'm using the super great Fog of War system using the custom shaders, which work great. The only issue I'm running into is when I'm in the editor, the terrain shader and all the individual items which I have the FoW style shader on are completely black.

Is there a way to get them to render as though everything were visible when the editor is open and the application is not playing?


Pages: [1]