JetFistGames.RetroTVFX.CRTEffect.blitQuad(UnityEngine.Rect, UnityEngine.RenderTexture, UnityEngine.RenderTexture, UnityEngine.Material, int)

Here are the examples of the csharp api JetFistGames.RetroTVFX.CRTEffect.blitQuad(UnityEngine.Rect, UnityEngine.RenderTexture, UnityEngine.RenderTexture, UnityEngine.Material, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 View Source File : CRTEffect.cs
License : MIT License
Project Creator : GlaireDaggers

void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            ensureResources();

            setKeyword("ANTI_FLICKER", this.AntiFlicker, ref this.antiFlickerEnabled);
            setKeyword("ROLLING_FLICKER", this.EnableRollingFlicker, ref this.rollingFlickerEnabled);
            setKeyword("PIXEL_MASK", this.EnablePixelMask, ref this.pixelMaskEnabled);
            setKeyword("USE_TV_CURVATURE", this.EnableTVCurvature, ref this.tvCurvatureEnabled);
            setKeyword("QUANTIZE_RGB", this.QuantizeRGB, ref this.quantizeRGBEnabled);
            setKeyword("RF_SIGNAL", this.VideoMode == VideoType.RF, ref this.rfEnabled);

            if (compositeTemp == null || compositeTemp.width != DisplaySizeX || compositeTemp.height != DisplaySizeY)
            {
                if (compositeTemp != null)
                    RenderTexture.ReleaseTemporary(compositeTemp);

                compositeTemp = RenderTexture.GetTemporary(DisplaySizeX, DisplaySizeY, src.depth, RenderTextureFormat.ARGBHalf);
            }

            if (QuantizeRGB)
            {
                Vector4 quantize = new Vector4(Mathf.Pow(2f, RBits), Mathf.Pow(2f, GBits), Mathf.Pow(2f, BBits), 1f);
                Vector4 oneOverQuantize = new Vector4(1f / quantize.x, 1f / quantize.y, 1f / quantize.z, 1f);

                material.SetVector("_QuantizeRGB", quantize);
                material.SetVector("_OneOverQuantizeRGB", oneOverQuantize);
            }

			material.SetFloat("_Realtime", Time.realtimeSinceStartup);

            material.SetVector("_IQOffset", new Vector4(IQScale.x, IQScale.y, IQOffset.x, IQOffset.y));
            material.SetMatrix("_RGB2YIQ_MAT", this.rgb2yiq_mat);
            material.SetMatrix("_YIQ2RGB_MAT", this.yiq2rgb_mat);

            material.SetFloat("_RFNoise", this.RFNoise);
			material.SetFloat("_LumaSharpen", this.LumaSharpen);

            material.SetInt("_Framecount", -this.frameCount);
            material.SetVector("_ScreenSize", new Vector4(DisplaySizeX, DisplaySizeY, 1f / DisplaySizeX, 1f / DisplaySizeY));

            material.SetFloat("_RollingFlickerAmount", this.RollingFlickerFactor);
            material.SetVector("_FlickerOffs", new Vector4(this.flickerOffset, this.flickerOffset + RollingVSyncTime, 0f, 0f));

            material.SetVector("_PixelMaskScale", new Vector4(MaskRepeatX, MaskRepeatY));
            material.SetTexture("_PixelMask", PixelMaskTexture);
            material.SetFloat("_Brightness", PixelMaskBrightness);

            material.SetFloat("_TVCurvature", Curvature);
            

            RenderTexture preplaced1 = RenderTexture.GetTemporary(DisplaySizeX, DisplaySizeY, src.depth, RenderTextureFormat.ARGBHalf);
			//preplaced1.filterMode = FilterMode.Point;
			RenderTexture preplaced2 = RenderTexture.GetTemporary(DisplaySizeX, DisplaySizeY, src.depth, RenderTextureFormat.ARGBHalf);
			//preplaced2.filterMode = FilterMode.Point;

            RenderTexture lastComposite = RenderTexture.GetTemporary(DisplaySizeX, DisplaySizeY, src.depth, RenderTextureFormat.ARGBHalf);

            RenderTexture final = preplaced1;

            if (this.VideoMode == VideoType.Composite || this.VideoMode == VideoType.RF)
            {
                Graphics.Blit(src, preplaced1);

				Graphics.Blit(preplaced1, preplaced2, material, Preplaced_COMPOSITE_ENCODE);

				// preplaced last frame's signal and save current frame's signal
				Graphics.Blit(compositeTemp, lastComposite);
				Graphics.Blit(preplaced2, compositeTemp);
				material.SetTexture("_LastCompositeTex", lastComposite);
				
				Graphics.Blit(preplaced2, preplaced1, material, Preplaced_COMPOSITE_DECODE);
				Graphics.Blit(preplaced1, preplaced2, material, Preplaced_COMPOSITE_FINAL);

				final = preplaced2;
			}
            else if (this.VideoMode == VideoType.SVideo)
            {
                Graphics.Blit(src, preplaced1);

                Graphics.Blit(preplaced1, preplaced2, material, Preplaced_SVIDEO_ENCODE);

                // preplaced last frame's signal and save current frame's signal
                Graphics.Blit(compositeTemp, lastComposite);
                Graphics.Blit(preplaced2, compositeTemp);
                material.SetTexture("_LastCompositeTex", lastComposite);

                Graphics.Blit(preplaced2, preplaced1, material, Preplaced_SVIDEO_DECODE);
            }
            else if (this.VideoMode == VideoType.VGA)
            {
                Graphics.Blit(src, preplaced1, material, Preplaced_VGA);
            }
            else if (this.VideoMode == VideoType.VGAFast)
            {
                final = src;
            }
            else if (this.VideoMode == VideoType.Component)
            {
                Graphics.Blit(src, preplaced1, material, Preplaced_COMPONENT);
            }

            //Graphics.Blit(final, dest, material, Preplaced_TV_OVERLAY);
            if (StretchToDisplay)
                blitQuad(final, dest, material, Preplaced_TV_OVERLAY);
            else
            {
                float screenAspect = (float)Screen.width / (float)Screen.height;

                if (screenAspect < AspectRatio)
                {
                    // fit to screen width
                    float width = 1f;
                    float height = screenAspect / AspectRatio;
                    float heightDiff = 1f - height;

                    blitQuad(new Rect(0f, heightDiff * 0.5f, width, height), final, dest, material, Preplaced_TV_OVERLAY);
                }
                else
                {
                    // fit to screen height
                    float height = 1f;
                    float width = (1f / screenAspect) * AspectRatio;
                    float widthDiff = 1f - width;

                    blitQuad(new Rect(widthDiff * 0.5f, 0f, width, height), final, dest, material, Preplaced_TV_OVERLAY);
                }
            }

            RenderTexture.ReleaseTemporary(preplaced1);
            RenderTexture.ReleaseTemporary(preplaced2);
            RenderTexture.ReleaseTemporary(lastComposite);
        }

19 View Source File : CRTEffect.cs
License : MIT License
Project Creator : GlaireDaggers

private void blitQuad(RenderTexture src, RenderTexture dest, Material material, int preplaced)
        {
            blitQuad(new Rect(0f, 0f, 1f, 1f), src, dest, material, preplaced);
        }