Example #1
0
    public void Init(FOWData data)
    {
        m_FOWData = data;

        int length = m_FOWData.m_TexWidth * m_FOWData.m_TexHeight;

        if (m_Fowtexture == null)
        {
            m_Fowtexture            = new RenderTexture(texWidth, texHeight, 0, RenderTextureFormat.ARGB32);
            m_Fowtexture.wrapMode   = TextureWrapMode.Clamp;
            m_Fowtexture.filterMode = FilterMode.Bilinear;
            m_Fowtexture.Create();
        }

        if (m_SDFMaterial == null)
        {
            m_SDFMaterial = new Material(Shader.Find("Hidden/FOWJumpFloodSDF"));
        }

        if (m_ShadowSDFMaterial == null)
        {
            m_ShadowSDFMaterial = new Material(Shader.Find("Hidden/FOWShadowSDF"));
        }

        if (m_BlurMaterial == null)
        {
            m_BlurMaterial = new Material(Shader.Find("Hidden/FOWBlurSDF"));
        }

        if (m_MapData == null)
        {
            m_MapData = new FOWMapData();
            m_MapData.Init(data);
        }

        if (m_SDFBuffer == null)
        {
            m_SDFBuffer = new Color[length];
        }

        if (m_SDFTexture == null)
        {
            m_SDFTexture            = new Texture2D(texWidth, texHeight, TextureFormat.ARGB32, false);
            m_SDFTexture.wrapMode   = TextureWrapMode.Clamp;
            m_SDFTexture.filterMode = FilterMode.Bilinear;
        }

        if (texWidth > texHeight)
        {
            m_TextureSizeScale = new Vector2(1.0f, (float)texHeight / texWidth);
        }
        else
        {
            m_TextureSizeScale = new Vector2((float)texWidth / texHeight, 1.0f);
        }

        m_TextureTexelSize = new Vector2(1.0f / texWidth, 1.0f / texHeight);
    }
Example #2
0
    public void Init(FOWData data = null)
    {
        if (data != null)
        {
            m_FOWData = data;
        }

        int length = texWidth * texHeight;

        // regenerate when attributes changed
        if (m_MaskCache == null || m_MaskCache.Length != length)
        {
            m_MaskCache = new byte[length];
        }

        if (m_ColorBuffer == null || m_ColorBuffer.Length != length)
        {
            m_ColorBuffer = new Color[length];
        }

        // regenerate the texture if necessary
        if (m_MaskTexture == null ||
            m_MaskTexture.width != texWidth ||
            m_MaskTexture.height != texHeight)
        {
            if (m_MaskTexture != null)
            {
                Object.DestroyImmediate(m_MaskTexture);
                m_MaskTexture = null;
            }

            m_MaskTexture            = new Texture2D(texWidth, texHeight, TextureFormat.ARGB32, false);
            m_MaskTexture.wrapMode   = TextureWrapMode.Clamp;
            m_MaskTexture.filterMode = FilterMode.Bilinear;
        }

        if (m_RootPixelQueue == null)
        {
            m_RootPixelQueue = new Queue <Vector2Int>();
        }

        if (m_ArrivedPixels == null)
        {
            m_ArrivedPixels = new List <int>();
        }

        if (m_Lock == null)
        {
            m_Lock = new object();
        }
    }
Example #3
0
    public void Init(FOWData data = null)
    {
        if (data != null)
        {
            m_FOWData = data;
        }

        if (m_Fowtexture == null ||
            m_Fowtexture.width != texWidth ||
            m_Fowtexture.height != texHeight)
        {
            if (m_Fowtexture != null)
            {
                Object.DestroyImmediate(m_Fowtexture);
                m_Fowtexture = null;
            }

            m_Fowtexture            = new RenderTexture(texWidth, texHeight, 0, RenderTextureFormat.ARGB32);
            m_Fowtexture.wrapMode   = TextureWrapMode.Clamp;
            m_Fowtexture.filterMode = FilterMode.Bilinear;
            m_Fowtexture.Create();
        }

        if (m_BlurMaterial == null)
        {
            m_BlurMaterial = new Material(Shader.Find("Hidden/FOWBlur"));
        }

        // Generate map data
        if (m_Map == null)
        {
            m_Map = new FOWMap(data);
        }

        m_TextureTexelSize = new Vector2(1.0f / texWidth, 1.0f / texHeight);
    }
Example #4
0
 public FOWShadowSDF(FOWData data)
 {
     Init(data);
 }
Example #5
0
 public FOWShadowDota(FOWData data)
 {
     Init(data);
 }