Esempio n. 1
0
        protected void CreateRenderTextures(int w, int h)
        {
            if (this.WriteAlpha)
            {
                this.alpha_buffer = GraphicsUtils.GetRenderTexture(w, h, 0, RenderTextureFormat.R8);
            }
            this.downsample4X_buffer = GraphicsUtils.GetRenderTexture(w / 4, h / 4, 0x10, this.internalBufferFormat);
            if (this.UseDistortion)
            {
                this.CreateDistortionMap(w, h);
            }
            if (this.UseRadialBlur)
            {
                int radialBlurDownScale = (int)this.RadialBlurDownScale;
                this.radial_blur_buffer      = GraphicsUtils.GetRenderTexture(w / radialBlurDownScale, h / radialBlurDownScale, 0, this.internalBufferFormat);
                this.radial_blur_buffer_temp = GraphicsUtils.GetRenderTexture(w / radialBlurDownScale, h / radialBlurDownScale, 0, this.internalBufferFormat);
            }
            int internalBufferSize = (int)this.internalBufferSize;
            int width = (int)this.internalBufferSize;

            this.gauss_buffer = GraphicsUtils.GetRenderTexture(width, width, 0, RenderTextureFormat.ARGBHalf);
            this.gauss_buffer.content.filterMode = FilterMode.Bilinear;
            for (int i = 0; i < 6; i++)
            {
                this.compose_buffer[i] = GraphicsUtils.GetRenderTexture(internalBufferSize, width, 0, this.internalBufferFormat);
                this.blur_bufferA[i]   = GraphicsUtils.GetRenderTexture(internalBufferSize, width, 0, this.internalBufferFormat);
                this.blur_bufferB[i]   = GraphicsUtils.GetRenderTexture(internalBufferSize, width, 0, this.internalBufferFormat);
                internalBufferSize    /= 2;
                width /= 2;
            }
        }
Esempio n. 2
0
        private void DoSetupRenderTexture()
        {
            if (this._renderTexture != null)
            {
                GraphicsUtils.ReleaseRenderTexture(this._renderTexture);
                this._renderTexture = null;
            }
            base.transform.GetComponent <RawImage>().enabled = true;
            float  scaleFactor = 1f;
            Canvas component   = Singleton <MainUIManager> .Instance.SceneCanvas.GetComponent <Canvas>();

            if ((component != null) && (component.renderMode != RenderMode.WorldSpace))
            {
                scaleFactor = component.scaleFactor;
            }
            float width  = ((RectTransform)base.transform).rect.width;
            float height = ((RectTransform)base.transform).rect.height;

            this._renderTexture = GraphicsUtils.GetRenderTexture((int)(width * scaleFactor), (int)(height * scaleFactor), 0x18, RenderTextureFormat.ARGB32);
            this._renderTexture.content.filterMode           = FilterMode.Point;
            base.transform.GetComponent <RawImage>().texture = (Texture)this._renderTexture;
            GameObject obj2 = GameObject.Find("MainCamera");

            if (obj2 != null)
            {
                this._renderTexture.BindToCamera(obj2.GetComponent <Camera>());
            }
        }
Esempio n. 3
0
 public static void ReleaseRenderTexture(RenderTextureWrapper wrapper)
 {
     if (wrapper != null)
     {
         _renderTextureWrapperPool.ReleaseItem(wrapper);
     }
 }
Esempio n. 4
0
        public static RenderTextureWrapper GetRenderTexture(RenderTextureWrapper.Param param)
        {
            RenderTextureWrapper item = _renderTextureWrapperPool.GetItem();

            item.Create(param);
            return(item);
        }
Esempio n. 5
0
        public void OnPostRender()
        {
            RenderTexture source        = (RenderTexture)this._rplCameraBuffer;
            RenderTexture targetTexture = base._camera.targetTexture;

            if (((this.CameraResScale == CAMERA_RES_SCALE.RES_400) && (this.CameraResWidth == 0)) && (this.CameraResHeight == 0))
            {
                RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(source.width, source.height, 0, base.internalBufferFormat);
                if (this.OnlyResScale)
                {
                    Graphics.Blit(source, (RenderTexture)wrapper);
                    base.CheckResources();
                }
                else
                {
                    base.DoPostProcess(source, (RenderTexture)wrapper);
                }
                base.DownSample4X.SetVector(PostFXBase.HASH_TEXEL_SIZE, new Vector2(1f / ((float)source.width), 1f / ((float)source.height)));
                Graphics.Blit((Texture)wrapper, targetTexture, base.DownSample4X, 0);
                GraphicsUtils.ReleaseRenderTexture(wrapper);
            }
            else if (this.OnlyResScale)
            {
                Graphics.Blit((Texture)this._rplCameraBuffer, targetTexture);
            }
            else
            {
                base.DoPostProcess((RenderTexture)this._rplCameraBuffer, targetTexture);
            }
        }
Esempio n. 6
0
 private void OnDestroy()
 {
     if (this._renderTexture != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._renderTexture);
         this._renderTexture = null;
     }
 }
Esempio n. 7
0
 protected override void OnDestroy()
 {
     if (this.__rplCameraBuffer != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this.__rplCameraBuffer);
         this.__rplCameraBuffer = null;
     }
     base.OnDestroy();
 }
Esempio n. 8
0
 public void ReleaseItem(RenderTextureWrapper item)
 {
     if (item != null)
     {
         item.__Release();
         this._usedList.Remove(item);
         this._availableList.Add(item);
     }
 }
Esempio n. 9
0
        private void ApplyHexBlur()
        {
            if (this._hexBlurMat == null)
            {
                this._hexBlurMat = new Material(this.hexBlurShader);
            }
            RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(this._reflectionRenderTex.width, this._reflectionRenderTex.height, 0, this.bufferFormat);

            ReflectionTool.ApplyHexBlur(this._hexBlurMat, (RenderTexture)this._reflectionRenderTex, (RenderTexture)wrapper, this.hexBlurFactor, 0f, 0.5f, 1);
            ReflectionTool.ApplyHexBlur(this._hexBlurMat, (RenderTexture)wrapper, (RenderTexture)this._reflectionRenderTex, this.hexBlurFactor, 0f, 0.5f, 1);
            GraphicsUtils.ReleaseRenderTexture(wrapper);
        }
Esempio n. 10
0
 protected virtual void OnDisable()
 {
     if (this._reflectionRenderTex != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._reflectionRenderTex);
         this._reflectionRenderTex = null;
     }
     if (_reflectionCamera != null)
     {
         UnityEngine.Object.DestroyImmediate(_reflectionCamera.gameObject);
         _reflectionCamera = null;
     }
 }
Esempio n. 11
0
 public void ReleaseRenderTexture()
 {
     if (this._renderTexture != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._renderTexture);
         this._renderTexture = null;
         GameObject obj2 = GameObject.Find("MainCamera");
         if (obj2 != null)
         {
             obj2.GetComponent <Camera>().targetTexture = null;
         }
     }
 }
Esempio n. 12
0
        private void Start()
        {
            this._innerCamera         = base.GetComponentInChildren <Camera>();
            this._innerCamera.enabled = true;
            this._innerCamera.SetReplacementShader(this.Shader, string.Empty);
            this._renderTexture             = GraphicsUtils.GetRenderTexture(this.size, this.size, 0, this.format);
            this._innerCamera.targetTexture = (RenderTexture)this._renderTexture;
            this._projector = base.GetComponent <Projector>();
            Material material = new Material(this.ProjectorShader);

            material.SetTexture("_Cookie", (Texture)this._renderTexture);
            material.SetTexture("_FalloffTex", this.FallOffTex);
            this._projector.material = material;
            this._rootNodeTransform  = base.GetComponentInParent <BaseMonoAnimatorEntity>().RootNode;
        }
Esempio n. 13
0
 private void CreateRenderTextures(int w, int h)
 {
     if (!this.HighQuality)
     {
         this.temp_buffer = GraphicsUtils.GetRenderTexture(w, h, 0, this.internalBufferFormat);
     }
     else
     {
         this.temp_buffer  = GraphicsUtils.GetRenderTexture(w, h, 0, this.internalBufferFormatHQ);
         this.temp_buffers = new RenderTextureWrapper[this.blurLevel];
         for (int i = 0; i < this.blurLevel; i++)
         {
             this.temp_buffers[i] = GraphicsUtils.GetRenderTexture(w, h, 0, this.internalBufferFormatHQ);
         }
     }
 }
Esempio n. 14
0
        public RenderTextureWrapper GetItem()
        {
            RenderTextureWrapper wrapper;

            if (this._availableList.Count > 0)
            {
                wrapper = this._availableList[0];
                this._availableList.RemoveAt(0);
            }
            else
            {
                wrapper = new RenderTextureWrapper();
            }
            this._usedList.Add(wrapper);
            return(wrapper);
        }
Esempio n. 15
0
 private void ReleaseBuffers()
 {
     if (this._farCameraBuffer != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._farCameraBuffer);
         this._farCameraBuffer = null;
     }
     if (this._farBackgroundBuffer1 != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._farBackgroundBuffer1);
         this._farBackgroundBuffer1 = null;
     }
     if (this._farBackgroundBuffer2 != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._farBackgroundBuffer2);
         this._farBackgroundBuffer2 = null;
     }
 }
Esempio n. 16
0
        private void CreateBuffers()
        {
            int width  = this._width / 2;
            int height = this._height / 2;

            if (this._farCameraBuffer == null)
            {
                this._farCameraBuffer = GraphicsUtils.GetRenderTexture(width, height, 0x10, this.bufferFormat);
            }
            if (this._farBackgroundBuffer1 == null)
            {
                this._farBackgroundBuffer1 = GraphicsUtils.GetRenderTexture(width, height, 0, this.bufferFormat);
            }
            if (this._farBackgroundBuffer2 == null)
            {
                this._farBackgroundBuffer2 = GraphicsUtils.GetRenderTexture(width / 2, height / 2, 0, this.bufferFormat);
            }
        }
Esempio n. 17
0
        private RenderTexture ApplyDOFtoBackground()
        {
            RenderTexture texture;
            RenderTexture texture2;
            int           num3;

            this.CreateBuffers();
            this.FarCamera.Render();
            int num  = (int)(this._width * this._bufferSizeScale);
            int num2 = (int)(this._height * this._bufferSizeScale);

            if (this.BackgroundBlurFactor < (maxBlurFactor / 2f))
            {
                texture  = (RenderTexture)this._farCameraBuffer;
                texture2 = (RenderTexture)this._farBackgroundBuffer1;
                num3     = 2;
            }
            else
            {
                texture = (RenderTexture)this._farBackgroundBuffer1;
                Graphics.Blit((Texture)this._farCameraBuffer, texture, this._downSampleMat, 0);
                texture2 = (RenderTexture)this._farBackgroundBuffer2;
                num3     = 2;
            }
            if (this.BokehQuality == BokehQualityEnum.Normal)
            {
                RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                this.ApplyHexBlur((RenderTexture)this._farCameraBuffer, (RenderTexture)wrapper, this.BackgroundBlurFactor, this.BokehIntensity, 1f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper, texture2, this.BackgroundBlurFactor, this.BokehIntensity, 2f / ((float)num3), 0);
                GraphicsUtils.ReleaseRenderTexture(wrapper);
                return(texture2);
            }
            if (this.BokehQuality == BokehQualityEnum.High)
            {
                RenderTextureWrapper wrapper2 = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                RenderTextureWrapper wrapper3 = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                this.ApplyHexBlur((RenderTexture)this._farCameraBuffer, (RenderTexture)wrapper2, this.BackgroundBlurFactor, this.BokehIntensity, 0.5f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper2, (RenderTexture)wrapper3, this.BackgroundBlurFactor, this.BokehIntensity, 1f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper3, texture2, this.BackgroundBlurFactor, this.BokehIntensity, 2f / ((float)num3), 0);
                GraphicsUtils.ReleaseRenderTexture(wrapper2);
                GraphicsUtils.ReleaseRenderTexture(wrapper3);
            }
            return(texture2);
        }
Esempio n. 18
0
 private void ReleaseRenderTextures()
 {
     if (this.temp_buffer != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this.temp_buffer);
         this.temp_buffer = null;
     }
     if (this.HighQuality)
     {
         for (int i = 0; i < this.blurLevel; i++)
         {
             if (this.temp_buffers[i] != null)
             {
                 GraphicsUtils.ReleaseRenderTexture(this.temp_buffers[i]);
                 this.temp_buffers[i] = null;
             }
         }
     }
 }
Esempio n. 19
0
        private void SaveImage(string fileName)
        {
            RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(this.imageSize, this.imageSize, 0, RenderTextureFormat.ARGB32);

            this.mainCamera.targetTexture = (RenderTexture)wrapper;
            this._postFX.WriteAlpha       = true;
            this.mainCamera.Render();
            this._postFX.WriteAlpha       = false;
            this.mainCamera.targetTexture = null;
            RenderTexture.active          = (RenderTexture)wrapper;
            Texture2D textured = new Texture2D(wrapper.width, wrapper.height, TextureFormat.ARGB32, false);

            textured.ReadPixels(new Rect(0f, 0f, (float)wrapper.width, (float)wrapper.height), 0, 0);
            textured.Apply();
            byte[] bytes = textured.EncodeToPNG();
            File.WriteAllBytes(string.Format("{0}/{1}.png", this.outputPath, fileName), bytes);
            UnityEngine.Object.Destroy(textured);
            GraphicsUtils.ReleaseRenderTexture(wrapper);
        }
Esempio n. 20
0
        private void CreateBuffers()
        {
            int width  = ((int)(this._width * this._bufferSizeScale)) / 2;
            int height = ((int)(this._height * this._bufferSizeScale)) / 2;

            if (this._farCameraBuffer == null)
            {
                this._farCameraBuffer = GraphicsUtils.GetRenderTexture(width, height, 0x10, this.bufferFormat);
            }
            if (this._farBackgroundBuffer1 == null)
            {
                this._farBackgroundBuffer1 = GraphicsUtils.GetRenderTexture(width, height, 0, this.bufferFormat);
            }
            if (this._farBackgroundBuffer2 == null)
            {
                this._farBackgroundBuffer2 = GraphicsUtils.GetRenderTexture(width / 2, height / 2, 0, this.bufferFormat);
            }
            this._compositionMat.SetTexture("_FarTex", (Texture)this._farCameraBuffer);
            this.FarCamera.targetTexture = (RenderTexture)this._farCameraBuffer;
        }
Esempio n. 21
0
        private RenderTexture ApplyDOF(RenderTexture texture)
        {
            RenderTexture texture2;
            RenderTexture texture3;
            int           num3;
            int           num  = this._width;
            int           num2 = this._height;

            if (this.backgroundBlurFactor < (_maxBlurFactor / 2f))
            {
                texture2 = (RenderTexture)this._farCameraBuffer;
                texture3 = (RenderTexture)this._farBackgroundBuffer1;
                num3     = 2;
            }
            else
            {
                texture2 = (RenderTexture)this._farBackgroundBuffer1;
                Graphics.Blit((Texture)this._farCameraBuffer, texture2, this._downSampleMat, 0);
                texture3 = (RenderTexture)this._farBackgroundBuffer2;
                num3     = 2;
            }
            if (this.bokehQuality == BokehQualityEnum.Normal)
            {
                RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                this.ApplyHexBlur(texture2, (RenderTexture)wrapper, this.backgroundBlurFactor, this.bokehIntensity, 1f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper, texture3, this.backgroundBlurFactor, this.bokehIntensity, 2f / ((float)num3), 0);
                GraphicsUtils.ReleaseRenderTexture(wrapper);
                return(texture3);
            }
            if (this.bokehQuality == BokehQualityEnum.High)
            {
                RenderTextureWrapper wrapper2 = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                RenderTextureWrapper wrapper3 = GraphicsUtils.GetRenderTexture(num / num3, num2 / num3, 0, this.bufferFormat);
                this.ApplyHexBlur(texture2, (RenderTexture)wrapper2, this.backgroundBlurFactor, this.bokehIntensity, 0.5f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper2, (RenderTexture)wrapper3, this.backgroundBlurFactor, this.bokehIntensity, 1f / ((float)num3), 0);
                this.ApplyHexBlur((RenderTexture)wrapper3, texture3, this.backgroundBlurFactor, this.bokehIntensity, 2f / ((float)num3), 0);
                GraphicsUtils.ReleaseRenderTexture(wrapper2);
                GraphicsUtils.ReleaseRenderTexture(wrapper3);
            }
            return(texture3);
        }
Esempio n. 22
0
 public void CleanUp()
 {
     if (this._setupWeapon3dModelCoroutine != null)
     {
         if (Singleton <ApplicationManager> .Instance != null)
         {
             Singleton <ApplicationManager> .Instance.StopCoroutine(this._setupWeapon3dModelCoroutine);
         }
         this._setupWeapon3dModelCoroutine = null;
     }
     if (this._containerGo != null)
     {
         UnityEngine.Object.Destroy(this._containerGo);
         this._containerGo = null;
     }
     if (this._renderTexture != null)
     {
         GraphicsUtils.ReleaseRenderTexture(this._renderTexture);
         this._renderTexture = null;
     }
 }
Esempio n. 23
0
 protected virtual void CreateObjects(Camera srcCam, ref RenderTextureWrapper renderTex, ref Camera destCam)
 {
     if ((renderTex == null) || (this._oldTexResScale != this.texResScale))
     {
         if (renderTex != null)
         {
             GraphicsUtils.ReleaseRenderTexture(renderTex);
         }
         renderTex = GraphicsUtils.GetRenderTexture((srcCam.pixelWidth * this.texResScale) / 100, (srcCam.pixelHeight * this.texResScale) / 100, 0x10, this.bufferFormat);
         renderTex.content.name      = "__RefRenderTexture" + renderTex.content.GetInstanceID();
         renderTex.content.hideFlags = HideFlags.DontSave;
         this._oldTexResScale        = this.texResScale;
     }
     if (destCam == null)
     {
         System.Type[] components = new System.Type[] { typeof(Camera) };
         GameObject    obj2       = new GameObject("__RefCamera for " + srcCam.GetInstanceID(), components);
         destCam                    = obj2.GetComponent <Camera>();
         destCam.enabled            = false;
         destCam.transform.position = base.transform.position;
         destCam.transform.rotation = base.transform.rotation;
         obj2.hideFlags             = HideFlags.HideAndDontSave;
     }
 }
Esempio n. 24
0
 protected virtual void CreateDistortionMap(int w, int h)
 {
     this.distortionMap = GraphicsUtils.GetRenderTexture(w / 2, h / 2, this.DistortionMapDepthBit, this.DistortionMapFormat);
 }