Example #1
0
        public void OnFrame(RGBTextureFrame frame)
        {
            // Render every camera
            TargetCamera.Render();

            switch (BlendMode)
            {
            case BlendMode.RGBOnly:
                Graphics.Blit(frame.texture, BlendTexture);
                break;

            case BlendMode.VirtualOnly:
                Graphics.Blit(TargetCamera.targetTexture, BlendTexture);
                break;

            case BlendMode.Blend:
                BlendMaterial.SetTexture("_MainTex", TargetCamera.targetTexture);
                BlendMaterial.SetTexture("_BcakGroundTex", frame.texture);
                Graphics.Blit(TargetCamera.targetTexture, BlendTexture, BlendMaterial);
                break;

            case BlendMode.WidescreenBlend:
                // TODO

                break;

            default:
                break;
            }

            // Commit frame
            Encoder.Commit(BlendTexture, frame.timeStamp);
        }
Example #2
0
        // Border generation
        private void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            MapMaterial.SetBuffer(ProvColorBuffer, _provLookup);
            // Passing which border to render.
            MapMaterial.SetFloat(CountryBorderToggle, _orthographicSize > 1.5f ? 0 : 1);

            var terrainTemp = RenderTexture.GetTemporary(src.descriptor);
            var oceanTemp   = RenderTexture.GetTemporary(src.descriptor);

            // Province coloring.
            Graphics.Blit(src, terrainTemp, MapMaterial);
            // Overlay combination. F**k Unity.
            // Terrain
            BlendMaterial.SetTexture(SecondTex, TerrainTexture);
            BlendMaterial.SetFloat(SkipDirection, 1);
            BlendMaterial.SetFloat(BlendStrength, 0.5f);
            Graphics.Blit(terrainTemp, oceanTemp, BlendMaterial);
            // Ocean
            BlendMaterial.SetTexture(SecondTex, OceanTexture);
            BlendMaterial.SetFloat(SkipDirection, 0);
            BlendMaterial.SetFloat(BlendStrength, 0.75f);
            Graphics.Blit(oceanTemp, dest, BlendMaterial);

            terrainTemp.Release();
            oceanTemp.Release();
        }
Example #3
0
 // lerps between previous and next weather texture
 IEnumerator LerpWeatherTexture()
 {
     isChangingWeather = true;
     for (float t = 0f; t <= blendTime; t += Time.deltaTime * (clouds.globalMultiplier == 0.0 ? blendTime : Mathf.Abs(clouds.globalMultiplier)))
     {
         BlendMaterial.SetTexture("_PrevWeather", prevWeatherTexture);
         BlendMaterial.SetTexture("_NextWeather", nextWeatherTexture);
         BlendMaterial.SetFloat("_Alpha", t / blendTime);
         Graphics.Blit(null, rt, BlendMaterial, 0);
         setWeatherTexture();
         yield return(null);
     }
     Graphics.Blit(nextWeatherTexture, rt);
     setWeatherTexture();
     isChangingWeather = false;
 }
Example #4
0
        private void Start()
        {
            _camera = Camera.main;
            _em     = World.DefaultGameObjectInjectionWorld.EntityManager;

            // Default political map mode.
            using (var provinces = _em.CreateEntityQuery(typeof(Province))
                                   .ToEntityArray(Allocator.TempJob))
            {
                _provLookup = new ComputeBuffer(provinces.Length, 16, ComputeBufferType.Structured);

                var provTable = new float4[provinces.Length];
                foreach (var provData in provinces.Select(provinceEntity => _em.GetComponentData <Province>(provinceEntity)))
                {
                    var color = _em.GetComponentData <Country>(provData.Owner).Color;
                    provTable[provData.Index] = new float4(color.r, color.g, color.b, color.a);
                }

                _provLookup.SetData(provTable);
            }

            // Ocean tiles special colors. Defined in Countries Load.
            BlendMaterial.SetVector(SkipColor, (Color) new Color32(0, 191, 255, 255));
        }