This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private const int CircleSegmentCount = 64; | |
| private const int CircleVertexCount = CircleSegmentCount + 2; | |
| private const int CircleIndexCount = CircleSegmentCount * 3; | |
| private static Mesh GenerateCircleMesh() | |
| { | |
| var circle = new Mesh(); | |
| var vertices = new List<Vector3>(CircleVertexCount); | |
| var indices = new int[CircleIndexCount]; | |
| var segmentWidth = Mathf.PI * 2f / CircleSegmentCount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef FOG_OF_WAR_INCLUDED | |
| #define FOG_OF_WAR_INCLUDED | |
| #ifdef FOG_OF_WAR | |
| # define FOG_OF_WAR_INPUT float3 worldPos; | |
| # define FOG_OF_WAR_SAMPLE(in_) FogOfWar_Sample(in_.worldPos) | |
| #else | |
| # define FOG_OF_WAR_INPUT | |
| # define FOG_OF_WAR_SAMPLE(in_) (1.0f) | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CGPROGRAM | |
| #pragma surface surf Standard fullforwardshadows | |
| #pragma target 3.0 | |
| #pragma multi_compile __ FOG_OF_WAR // <<< 1 | |
| #include "FogOfWar.cginc" // <<< 2 | |
| sampler2D _MainTex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef TERRAIN_SPLATMAP_INCLUDED | |
| #define TERRAIN_SPLATMAP_INCLUDED | |
| // Copied from Unity's TerrainSplatmapCommon.cginc | |
| #include "../FogOfWar.cginc" // <<< | |
| struct Input | |
| { | |
| float2 uv_Splat0 : TEXCOORD0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FogOfWarRevealable : MonoBehaviour | |
| { | |
| private List<FogOfWarRevealer> m_NearRevealers = new List<FogOfWarRevealer>(); | |
| private bool m_Revealed = true; | |
| private float m_NextFullUpdateTime; | |
| ... | |
| private void Start() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public override bool Reveals(Vector3 position, float radius) | |
| { | |
| var localPosition = m_Rectangle.transform.InverseTransformPoint(position); | |
| localPosition = Vector3.Scale(localPosition, m_Rectangle.transform.localScale); | |
| return localPosition.x >= -m_Extent.x - radius | |
| && localPosition.x <= m_Extent.x + radius | |
| && localPosition.z >= -m_Extent.y - radius | |
| && localPosition.z <= m_Extent.y + radius; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fixed FogOfWar_Sample(float3 worldPos) { | |
| #ifdef FOG_OF_WAR | |
| float2 uv = worldPos.xz / _MapSize.xy + 0.5f; | |
| fixed fow = tex2D(_FogOfWarTex, uv).r * 0.75f + 0.25f; | |
| #else | |
| fixed fow = 1; | |
| #endif | |
| float SMOOTH_LENGTH = 5.0f; // <<< | |
| float2 dist = min((_MapSize.zw - worldPos.xz), (_MapSize.zw + worldPos.xz)); // <<< | |
| float2 ratio = dist / SMOOTH_LENGTH; // <<< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fixed FogOfWar_Sample(float3 worldPos) { | |
| float2 worldPosNorm = worldPos.xz / _MapSize.xy; | |
| #ifdef FOG_OF_WAR | |
| float2 fogOfWarUV = worldPosNorm + 0.5f; | |
| fixed fogOfWar = tex2D(_FogOfWarTex, fogOfWarUV).r * 0.75f + 0.25f; | |
| #else | |
| fixed fogOfWar = 1; | |
| #endif | |
| #ifdef MAP_BORDERS | |
| float noiseU = abs(worldPosNorm.x / worldPosNorm.y) > 1 ? worldPosNorm.y : worldPosNorm.x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "UnityCG.cginc" | |
| struct appdata | |
| { | |
| float4 vertex : POSITION; | |
| float2 uv : TEXCOORD0; | |
| }; | |
| struct v2f | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void IndexedGraphicsBlit(RenderTexture source, RenderTexture dest, Material material) | |
| { | |
| RenderTexture.active = dest; | |
| material.SetTexture("_MainTex", source); | |
| GL.PushMatrix(); | |
| GL.LoadOrtho(); | |
| material.SetPass(0); |
OlderNewer