Blit() 공개 정적인 메소드

public static Blit ( RenderTexture source, Rect sourceRect, RenderTexture dest, Rect destRect, BlendMode, blendMode ) : void
source RenderTexture
sourceRect Rect
dest RenderTexture
destRect Rect
blendMode BlendMode,
리턴 void
    // Called by the camera to apply the image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        RenderTexture buffer  = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
        RenderTexture buffer2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);

        // Copy source to the 4x4 smaller texture.
        DownSample4x(source, buffer);

        // Blur the small texture
        bool oddEven = true;

        for (int i = 0; i < iterations; i++)
        {
            if (oddEven)
            {
                FourTapCone(buffer, buffer2, i);
            }
            else
            {
                FourTapCone(buffer2, buffer, i);
            }
            oddEven = !oddEven;
        }
        if (oddEven)
        {
            ImageEffects.Blit(buffer, destination);
        }
        else
        {
            ImageEffects.Blit(buffer2, destination);
        }

        RenderTexture.ReleaseTemporary(buffer);
        RenderTexture.ReleaseTemporary(buffer2);
    }
예제 #2
0
    // Called by camera to apply image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        // Create the accumulation texture
        if (accumTexture == null || accumTexture.width != source.width || accumTexture.height != source.height)
        {
            DestroyImmediate(accumTexture);
            accumTexture           = new RenderTexture(source.width, source.height, 0);
            accumTexture.hideFlags = HideFlags.HideAndDontSave;
            ImageEffects.Blit(source, accumTexture);
        }

        // If Extra Blur is selected, downscale the texture to 4x4 smaller resolution.
        if (extraBlur)
        {
            RenderTexture blurbuffer = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
            ImageEffects.Blit(accumTexture, blurbuffer);
            ImageEffects.Blit(blurbuffer, accumTexture);
            RenderTexture.ReleaseTemporary(blurbuffer);
        }

        // Clamp the motion blur variable, so it can never leave permanent trails in the image
        blurAmount = Mathf.Clamp(blurAmount, 0.0f, 0.92f);

        // Setup the texture and floating point values in the shader
        material.SetTexture("_MainTex", accumTexture);
        material.SetFloat("_AccumOrig", 1.0F - blurAmount);

        // Render the image using the motion blur shader
        Graphics.Blit(source, accumTexture, material);
        Graphics.Blit(accumTexture, destination);
    }
예제 #3
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        RenderTexture temporary  = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);
        RenderTexture temporary2 = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);

        this.DownSample4x(source, temporary);
        bool flag = true;

        for (int i = 0; i < this.iterations; i++)
        {
            if (flag)
            {
                this.FourTapCone(temporary, temporary2, i);
            }
            else
            {
                this.FourTapCone(temporary2, temporary, i);
            }
            flag = !flag;
        }
        if (flag)
        {
            ImageEffects.Blit(temporary, destination);
        }
        else
        {
            ImageEffects.Blit(temporary2, destination);
        }
        RenderTexture.ReleaseTemporary(temporary);
        RenderTexture.ReleaseTemporary(temporary2);
    }
예제 #4
0
    public static void Blit(RenderTexture source, RenderTexture dest, BlendMode blendMode)
    {
        Rect rect     = new Rect(0f, 0f, 1f, 1f);
        Rect arg_3B_1 = rect;
        Rect destRect = new Rect(0f, 0f, 1f, 1f);

        ImageEffects.Blit(source, arg_3B_1, dest, destRect, blendMode);
    }
예제 #5
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        blurMat  = new Material(Shader.Find("Casey-Screen/CannyEdgeDetect-GBlur"));
        sobelMat = new Material(Shader.Find("Casey-Screen/CannyEdgeDetect-Sobel"));
        blurMat.SetFloat("_Res", blurResolution);

        Graphics.Blit(source, blurTex, blurMat);

        ImageEffects.Blit(blurTex, sobelTex, sobelMat);

        Graphics.Blit(sobelTex, destination);
    }
예제 #6
0
    // Called by the camera to apply the image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        // Clamp parameters to sane values
        glowIntensity  = Mathf.Clamp(glowIntensity, 0.0f, 10.0f);
        blurIterations = Mathf.Clamp(blurIterations, 0, 30);
        blurSpread     = Mathf.Clamp(blurSpread, 0.5f, 1.0f);

        RenderTexture buffer  = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
        RenderTexture buffer2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);

        // Copy source to the 4x4 smaller texture.
        DownSample4x(source, buffer);

        // Blur the small texture
        float extraBlurBoost = Mathf.Clamp01((glowIntensity - 1.0f) / 4.0f);

        blurMaterial.color = new Color(1F, 1F, 1F, 0.25f + extraBlurBoost);

        bool oddEven = true;

        for (int i = 0; i < blurIterations; i++)
        {
            if (oddEven)
            {
                FourTapCone(buffer, buffer2, i);
            }
            else
            {
                FourTapCone(buffer2, buffer, i);
            }
            oddEven = !oddEven;
        }

        if (ImageEffects.shaders == null)
        {
            ImageEffects.shaders = blitShaders;
        }

        ImageEffects.Blit(source, destination, BlendMode.Blend);

        if (oddEven)
        {
            BlitGlow(buffer, destination);
        }
        else
        {
            BlitGlow(buffer2, destination);
        }

        RenderTexture.ReleaseTemporary(buffer);
        RenderTexture.ReleaseTemporary(buffer2);
    }
예제 #7
0
    public void RenderToTarget(Transform fellow, int index, float height, GameObject [] subMeshs)
    {
        height = height * _scale;
        int   row_count = size / delta;
        int   _x        = index / row_count;
        int   _y        = index % row_count;
        float uvdelta   = ((float)delta) / size;
        int   old_layer = fellow.gameObject.layer;

        camera.CopyFrom(Camera.main);
        camera.backgroundColor    = backgroundColor;
        camera.isOrthoGraphic     = true;
        camera.orthographicSize   = height / 2;
        camera.transform.position = fellow.position + Vector3.up * height / 2;
        camera.transform.forward  = new Vector3(0, 0, 1);
        float angle = Camera.main.transform.rotation.eulerAngles.y;

        camera.transform.Rotate(0, angle, 0, Space.Self);
        camera.transform.Translate(new Vector3(0, 0, -10), Space.Self);
        camera.targetTexture    = aimTarget;
        camera.cullingMask      = 1 << 30;
        camera.clearFlags       = CameraClearFlags.SolidColor;
        fellow.gameObject.layer = 30;
        if (null != subMeshs)
        {
            if (null != subMeshs[0])
            {
                subMeshs[0].layer = 30;
            }
            if (null != subMeshs[1])
            {
                subMeshs[1].layer = 30;
            }
        }
        //camera.RenderWithShader(Shader.Find("Hidden/Show Render Types"),"RenderType");
        camera.RenderWithShader(ShaderManager.GetInstance().KingSoftGhost.shader, "RenderType");
        fellow.gameObject.layer = old_layer;
        if (null != subMeshs)
        {
            if (null != subMeshs[0])
            {
                subMeshs[0].layer = old_layer;
            }
            if (null != subMeshs[1])
            {
                subMeshs[1].layer = old_layer;
            }
        }
        ImageEffects.Blit(aimTarget, new Rect(0, 0, 1, 1), renderTarget, new Rect(_x * uvdelta, _y * uvdelta, uvdelta, uvdelta), BlendMode.Copy);
        RenderMesh(list);
    }
예제 #8
0
    public override void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        RenderTexture temporary  = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);
        RenderTexture temporary2 = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);
        RenderTexture temporary3 = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);

        this.DownSample4x(source, temporary);
        bool flag = true;
        int  num  = 0;

        while ((float)num < this.iterations + this.iterations2)
        {
            if (flag)
            {
                this.FourTapCone(temporary, temporary2, num);
            }
            else
            {
                this.FourTapCone(temporary2, temporary, num);
            }
            flag = !flag;
            if ((float)num == this.iterations - (float)1)
            {
                ImageEffects.Blit((!flag) ? temporary2 : temporary, temporary3);
            }
            checked
            {
                num++;
            }
        }
        Material compositeMaterial = this.GetCompositeMaterial();

        compositeMaterial.SetTexture("_BlurTex1", temporary3);
        compositeMaterial.SetTexture("_BlurTex2", (!flag) ? temporary2 : temporary);
        compositeMaterial.SetTexture("_DepthTex", this.renderTexture);
        Shader.SetGlobalVector("_FocalParams", new Vector4(this.focalDistance, 1f / this.focalDistance, this.focalRange, 1f / this.focalRange));
        ImageEffects.BlitWithMaterial(compositeMaterial, source, destination);
        RenderTexture.ReleaseTemporary(temporary);
        RenderTexture.ReleaseTemporary(temporary2);
        RenderTexture.ReleaseTemporary(temporary3);
        if (this.renderTexture != null)
        {
            RenderTexture.ReleaseTemporary(this.renderTexture);
            this.renderTexture = null;
        }
    }
예제 #9
0
    // Called by camera to apply image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        // Create the accumulation texture
        if (accumTexture == null || accumTexture.width != source.width || accumTexture.height != source.height)
        {
            if (accumTexture != null)
            {
                DestroyImmediate(accumTexture);
            }
            accumTexture           = new RenderTexture(source.width, source.height, 0);
            accumTexture.hideFlags = HideFlags.HideAndDontSave;
            ImageEffects.Blit(source, accumTexture);
        }

        if (this.debugView)
        {
            //ImageEffects.Blit( source, accumTexture );
            Shader.EnableKeyword("MOTIONBLUREDGE_DEBUG");
            Shader.DisableKeyword("MOTIONBLUREDGE_NORMAL");
        }
        else
        {
            Shader.EnableKeyword("MOTIONBLUREDGE_NORMAL");
            Shader.DisableKeyword("MOTIONBLUREDGE_DEBUG");
        }

        // Clamp the motion blur variable, so it can never leave permanent trails in the image
//		blurAmount = Mathf.Clamp( blurAmount, 0.0f, 0.92f );
        endRadius   = Mathf.Clamp(endRadius, 0.01f, 10f);
        startRadius = Mathf.Clamp(startRadius, 0.01f, 10f);
        float scaledEndRad   = endRadius * source.height * 0.5f;
        float scaledStartRad = startRadius * source.height * 0.5f;
        float increaseFactor = 1.0f / (scaledEndRad - scaledStartRad);
        float startOffset    = increaseFactor * scaledStartRad;

        Shader.SetGlobalVector("_WindowsCorrection", new Vector4(source.width, source.height, 0, 0));
        // Setup the texture and floating point values in the shader
        material.SetTexture("_MainTex", accumTexture);
        material.SetFloat("_AccumOrig", 1.0F - blurAmount * speedFactor);         // * speedFactor);
        material.SetVector("_CenterPos", new Vector4(source.width * (0.5f + centerOffsetX), source.height * (0.5f + centerOffsetY), increaseFactor, startOffset));
        material.SetFloat("_TransitionCurve", transitionCurve);
        // Render the image using the motion blur shader
        ImageEffects.BlitWithMaterial(material, source, accumTexture);
        ImageEffects.Blit(accumTexture, destination);
    }
예제 #10
0
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            RenderTexture buffer  = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
            RenderTexture buffer2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);

            // Blur the source image. Since blurring is an expensive process, we want to do it at
            // quater resolution.
            // Copy the main screen image into an image at half size
            DownSample4x(source, new Rect(0, 0, 1, 1), buffer, new Rect(0, 0, 1, 1));

            // Blur the image by running the FourTapCone function on it i = blurLevels numbers of time.
            bool oddEven = true;

            for (int i = 0; i < blurLevels; i++)
            {
                if (oddEven)
                {
                    FourTapCone(buffer, new Rect(0, 0, 1, 1), buffer2, new Rect(0, 0, 1, 1), i);
                    oddEven = false;
                }
                else
                {
                    FourTapCone(buffer2, new Rect(0, 0, 1, 1), buffer, new Rect(0, 0, 1, 1), i);
                    oddEven = true;
                }
            }
            ImageEffects.Blit(source, destination);

            //bloomAmount = Mathf.Clamp01(bloomAmount);
            bloomMaterial.color = new Color(1F, 1F, 1F, bloomAmount);

            if (oddEven)
            {
                BlitBloom(buffer, destination);
            }
            else
            {
                BlitBloom(buffer2, destination);
            }

            RenderTexture.ReleaseTemporary(buffer);
            RenderTexture.ReleaseTemporary(buffer2);
        }
예제 #11
0
 private void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     if (this.accumTexture == null || this.accumTexture.get_width() != source.get_width() || this.accumTexture.get_height() != source.get_height())
     {
         Object.DestroyImmediate(this.accumTexture);
         this.accumTexture = new RenderTexture(source.get_width(), source.get_height(), 0);
         this.accumTexture.set_hideFlags(13);
         ImageEffects.Blit(source, this.accumTexture);
     }
     if (this.extraBlur)
     {
         RenderTexture temporary = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);
         ImageEffects.Blit(this.accumTexture, temporary);
         ImageEffects.Blit(temporary, this.accumTexture);
         RenderTexture.ReleaseTemporary(temporary);
     }
     this.blurAmount = Mathf.Clamp(this.blurAmount, 0f, 0.92f);
     base.material.SetTexture("_MainTex", this.accumTexture);
     base.material.SetFloat("_AccumOrig", 1f - this.blurAmount);
     Graphics.Blit(source, this.accumTexture, base.material);
     Graphics.Blit(this.accumTexture, destination);
 }
예제 #12
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        this.glowIntensity  = Mathf.Clamp(this.glowIntensity, 0f, 10f);
        this.blurIterations = Mathf.Clamp(this.blurIterations, 0, 30);
        this.blurSpread     = Mathf.Clamp(this.blurSpread, 0.5f, 1f);
        RenderTexture temporary  = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);
        RenderTexture temporary2 = RenderTexture.GetTemporary(source.get_width() / 4, source.get_height() / 4, 0);

        this.DownSample4x(source, temporary);
        float num = Mathf.Clamp01((this.glowIntensity - 1f) / 4f);

        GlowEffect.blurMaterial.set_color(new Color(1f, 1f, 1f, 0.25f + num));
        bool flag = true;

        for (int i = 0; i < this.blurIterations; i++)
        {
            if (flag)
            {
                this.FourTapCone(temporary, temporary2, i);
            }
            else
            {
                this.FourTapCone(temporary2, temporary, i);
            }
            flag = !flag;
        }
        ImageEffects.Blit(source, destination);
        if (flag)
        {
            this.BlitGlow(temporary, destination);
        }
        else
        {
            this.BlitGlow(temporary2, destination);
        }
        RenderTexture.ReleaseTemporary(temporary);
        RenderTexture.ReleaseTemporary(temporary2);
    }
예제 #13
0
 public static void Blit(RenderTexture source, RenderTexture dest)
 {
     ImageEffects.Blit(source, dest, BlendMode.Copy);
 }
예제 #14
0
 public static void Blit(RenderTexture source, RenderTexture dest, BlendMode blendMode)
 {
     ImageEffects.Blit(source, new Rect(0f, 0f, 1f, 1f), dest, new Rect(0f, 0f, 1f, 1f), blendMode);
 }