예제 #1
0
 private void T_Tick(object sender, EventArgs e)
 {
     if (sh)
     {
         if (a < 1)
         {
             a += 0.06f;
             c.ImageAttribute = ImageEffects.ChangeOpacity(a);
         }
         else
         {
             a = 1;
             t.Stop();
         }
     }
     else
     {
         if (a > 0)
         {
             a -= 0.06f;
             c.ImageAttribute = ImageEffects.ChangeOpacity(a);
         }
         else
         {
             a = 0;
             t.Stop();
             c.Hide();
         }
     }
     ((LayeredForm)c.FindForm()).LayeredPaint();
 }
예제 #2
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);
    }
예제 #3
0
        private void CreateCamera()
        {
            var cameraEntity = EntityManager.Find("camera");

            Camera2D camera = cameraEntity.FindComponent <Camera2D>();

            camera.FieldOfView     = MathHelper.ToRadians(45);
            camera.BackgroundColor = SceneResources.BackgroundColor;

            if (WaveServices.Platform.PlatformType == PlatformType.Windows ||
                WaveServices.Platform.PlatformType == PlatformType.Linux ||
                WaveServices.Platform.PlatformType == PlatformType.MacOS)
            {
                cameraEntity.AddComponent(ImageEffects.FishEye());
                cameraEntity.AddComponent(new ChromaticAberrationLens()
                {
                    AberrationStrength = 5.5f
                });
                cameraEntity.AddComponent(new RadialBlurLens()
                {
                    Center = new Vector2(0.5f, 0.75f), BlurWidth = 0.02f, Nsamples = 5
                });
                cameraEntity.AddComponent(ImageEffects.Vignette());
                //cameraEntity.AddComponent(new FilmGrainLens() { GrainIntensityMin = 0.075f, GrainIntensityMax = 0.15f });
            }
        }
예제 #4
0
    public static bool IsPro <T>(GameObject go, Type type, Shader s) where T : MonoBehaviour
    {
        bool isPro = Application.HasProLicense();

#if UNITY_EDITOR
        if (!isPro)
        {
            Debug.LogWarning("Image effects are not supported... But here is a little magic. Unfortunately as nothing is free, it will cost some performance.");
            ImageEffects ie = go.GetComponent <ImageEffects>();
            if (ie == null)
            {
                go.AddComponent <ImageEffects>();
                Debug.LogWarning("Move the ImageEffects component above the " + typeof(T) + " component.");
            }
        }
        else
        {
            DestroyImmediate(go.GetComponent <ImageEffects>());
        }

        // Disable if this shader is not supported
        if (!s || !s.isSupported)
        {
            Debug.Log(type.ToString() + " shader is not supported. I can't do anything about it.");
            go.GetComponent <T>().enabled = false;
        }
#endif
        return(isPro);
    }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of FastBitmap.
 /// </summary>
 /// <param name="width">The width in pixels of the FastBitmap</param>
 /// <param name="height">The height in pixels of the FastBitmap</param>
 public FastBitmap(int width, int height)
 {
     Width = width;
     Height = height;
     data = new FastColor[width, height];
     Effects = new ImageEffects(this);
 }
    // 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);
    }
예제 #7
0
 // Called by camera to apply image effect
 void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     material.SetTexture("_RampTex", textureRamp);
     material.SetFloat("_Desat", desaturateAmount);
     material.SetVector("_RampOffset", new Vector4(rampOffsetR, rampOffsetG, rampOffsetB, 0));
     ImageEffects.BlitWithMaterial(material, source, destination);
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of FastBitmap.
 /// </summary>
 /// <param name="width">The width in pixels of the FastBitmap</param>
 /// <param name="height">The height in pixels of the FastBitmap</param>
 public FastBitmap(int width, int height)
 {
     Width   = width;
     Height  = height;
     data    = new FastColor[width, height];
     Effects = new ImageEffects(this);
 }
예제 #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)
        {
            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);
    }
예제 #10
0
 public Bitmap DoEffect()
 {
     if (this.bool_0)
     {
         this.double_0 += this.double_2;
         this.double_1 += this.double_3;
         if (this.double_0 >= 1.0)
         {
             this.double_0 = 1.0;
             this.IsFinal  = true;
         }
         if (this.double_1 >= 1.0)
         {
             this.double_1 = 1.0;
         }
     }
     else
     {
         this.double_0 -= this.double_2;
         this.double_1 -= this.double_3;
         if (this.double_0 <= 0.7)
         {
             this.double_0 = 0.7;
             this.IsFinal  = true;
         }
         if (this.double_1 <= 0.01)
         {
             this.double_1 = 0.01;
         }
     }
     return(ImageEffects.TrapezoidTransformation(this.Original, this.double_0, this.double_1, this.bool_0, true));
 }
예제 #11
0
파일: Frost.cs 프로젝트: ahvonenj/TheForest
 public void OnPostRender()
 {
     if (!this.isPro)
     {
         ImageEffects.RenderImageEffect(this.material);
     }
 }
예제 #12
0
 /// <summary>
 /// 实现淡入淡出效果
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer2_Tick(object sender, EventArgs e)
 {
     if (isFadeIn)
     {
         if (opacity <= 1)
         {
             opacity += 0.06f;
         }
         if (opacity > 1)
         {
             opacity = 1;
             timer2.Stop();
         }
     }
     else
     {
         if (opacity >= 0)
         {
             opacity -= 0.06f;
         }
         if (opacity < 0)
         {
             opacity = 0;
             timer2.Stop();
         }
     }
     layeredPanel1.ImageAttribute = ImageEffects.ChangeOpacity(opacity);
     LayeredPaint();
 }
예제 #13
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);
    }
예제 #14
0
 // Update is called once per frame
 void Update()
 {
     if (Vector3.Distance(transform.position, Camera.main.transform.position) < transform.localScale.x * 0.505f)
     {
         ImageEffects imageEffects = Camera.main.GetComponent <ImageEffects>();
         imageEffects.color = atmosphereCol;
     }
 }
예제 #15
0
    // Use this for initialization

    void Start()
    {
        meshRenderer          = GetComponent <MeshRenderer>();
        meshRenderer.material = Resources.Load("Materials/gpuPlanet") as Material;

        meshRenderer.material.SetVector("_Center", transform.position);

        mainTex = GetRender(2);
        bumpMap = GetRender(1);
        clouds  = GetRender(0);

        meshRenderer.material = Resources.Load("Materials/planetSurface") as Material;

        meshRenderer.material.SetTexture("_MainTex", mainTex);
        meshRenderer.material.SetTexture("_Detail", Resources.Load("Textures/LandDetail") as Texture2D);
        meshRenderer.material.SetTexture("_Detail2", Resources.Load("Textures/WaterDetail") as Texture2D);
        meshRenderer.material.SetTexture("_Detail3", Resources.Load("Textures/CloudDetail") as Texture2D);
        meshRenderer.material.SetTexture("_Detail4", Resources.Load("Textures/LandDetail2") as Texture2D);
        meshRenderer.material.SetTexture("_BumpMap", bumpMap);
        meshRenderer.material.SetTexture("_Clouds", clouds);

        meshRenderer.material.SetVector("_Center", transform.position);

        meshRenderer.material.EnableKeyword("_NORMALMAP");

        Vector2
            pos = new Vector2(transform.position.x + transform.position.y, transform.position.z + transform.position.y);
        float
            r1     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.452f + 0.3f, pos.y * 0.452f + 0.281f)),
            g1     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.132f + 0.1f, pos.y * 0.132f + 0.399f)),
            b1     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.822f + 0.3f, pos.y * 0.822f + 0.125f)),
            r2     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.252f + 0.3f, pos.y * 0.452f + 0.290f)),
            g2     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.632f + 0.1f, pos.y * 0.332f + 0.383f)),
            b2     = Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.922f + 0.3f, pos.y * 0.322f + 0.183f)),
            clMovX = Mathf.PerlinNoise(pos.x * 0.822f + 0.3f, pos.y * 0.912f + 0.2f) / (2 * 500f),
            clMovY = Mathf.PerlinNoise(pos.x * 0.922f + 0.3f, pos.y * 0.822f + 0.1f) / (2 * 500f),
            p      = Mathf.Sqrt(Mathf.Abs(Mathf.PerlinNoise(pos.x * 0.401f + 0.3f, pos.y * 0.913f + 0.1f))) * 2.5f + 0.5f;

        gravity = p;

        Vector3 rimColor   = 1.5f * Vector3.Normalize(new Vector3(r1, g1, b1));
        Vector3 cloudColor = 1.5f * Vector3.Normalize(new Vector3(r2, g2, b2));

        atmosphereCol = new Color(rimColor.x, rimColor.y, rimColor.z);
        cloudCol      = new Color(cloudColor.x, cloudColor.y, cloudColor.z);

        meshRenderer.material.SetVector("_RimColor", rimColor);
        meshRenderer.material.SetFloat("_RimPower", p);
        meshRenderer.material.SetVector("_CloudColor", cloudCol);
        meshRenderer.material.SetVector("_CloudMovement", new Vector2(clMovX, clMovY));

        light = Light.GetLights(LightType.Directional, 0)[0];
        meshRenderer.material.SetVector("_Star", light.transform.position);

        m         = Camera.main.gameObject.GetComponentInParent <Movement>();
        imeffects = Camera.main.GetComponent <ImageEffects>();
    }
예제 #16
0
    // Downsamples the texture to a set resolution.
    private void DownSample(RenderTexture source, RenderTexture dest)
    {
        downsampleMaterial.SetFloat("_DownsampleAmount", downsampleAmount);

        // Remove colors below the threshold.
        downsampleMaterial.SetFloat("_GlowThreshold", glowThreshold);

        downsampleMaterial.color = new Color(glowTint.r, glowTint.g, glowTint.b, glowTint.a / downsampleAmount);
        ImageEffects.BlitWithMaterial(downsampleMaterial, source, dest);
    }
예제 #17
0
    public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
    {
        Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);

        material.SetMatrix("_RotationMatrix", rotationMatrix);
        material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
        material.SetFloat("_Angle", angle * Mathf.Deg2Rad);

        ImageEffects.BlitWithMaterial(material, source, destination);
    }
예제 #18
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);
    }
예제 #19
0
    public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
    {
        Matrix4x4 matrix4x = Matrix4x4.TRS(Vector3.get_zero(), Quaternion.Euler(0f, 0f, angle), Vector3.get_one());

        material.SetMatrix("_RotationMatrix", matrix4x);
        string  arg_56_1 = "_CenterRadius";
        Vector4 vector   = new Vector4(center.x, center.y, radius.x, radius.y);

        material.SetVector(arg_56_1, vector);
        material.SetFloat("_Angle", angle * 0.0174532924f);
        ImageEffects.BlitWithMaterial(material, source, destination);
    }
예제 #20
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);
    }
예제 #21
0
 public static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture destination)
 {
     RenderTexture.set_active(destination);
     material.SetTexture("_MainTex", source);
     GL.PushMatrix();
     GL.LoadOrtho();
     for (int i = 0; i < material.get_passCount(); i++)
     {
         material.SetPass(i);
         ImageEffects.DrawQuad();
     }
     GL.PopMatrix();
 }
예제 #22
0
 public void BlitBloom(RenderTexture source, RenderTexture dest)
 {
     // Make the destination texture the target for all rendering
     RenderTexture.active = dest;
     // Assign the source texture to a property from a shader
     source.SetGlobalShaderProperty("__RenderTex");
     // Set up the simple Matrix
     GL.PushMatrix();
     GL.LoadOrtho();
     bloomMaterial.SetPass(0);
     ImageEffects.DrawGrid(1, 1);
     GL.PopMatrix();
 }
예제 #23
0
파일: BaiduAi.cs 프로젝트: fengrui358/Labs
 public BaiduAi(ILogger <BaiduAi> logger, Orc orc, FaceRecognition faceRecognition, BodyAnalysis bodyAnalysis, Speech speech,
                ImageClassify imageClassify, ImageSearch imageSearch, ImageEffects imageEffects, Nlp nlp)
 {
     _logger          = logger;
     _orc             = orc;
     _faceRecognition = faceRecognition;
     _bodyAnalysis    = bodyAnalysis;
     _speech          = speech;
     _imageClassify   = imageClassify;
     _imageSearch     = imageSearch;
     _imageEffects    = imageEffects;
     _nlp             = nlp;
 }
예제 #24
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);
    }
예제 #25
0
    // Token: 0x06000FB0 RID: 4016 RVA: 0x00065568 File Offset: 0x00063768
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (Camera.main)
        {
            Camera.main.depthTextureMode |= DepthTextureMode.Depth;
        }
        float num   = base.camera.farClipPlane - base.camera.nearClipPlane;
        float value = this.fadeDistance / num;
        float angle = Mathf.Cos(Time.time) * this.maxAngle;

        base.material.SetTexture("_RampTex", this.textureRamp);
        base.material.SetFloat("_FadeDistance", value);
        base.material.SetFloat("_EffectWeight", this.effectWeight);
        ImageEffects.RenderDistortion(base.material, source, destination, angle, this.center, this.radius);
    }
예제 #26
0
파일: Tool.cs 프로젝트: Jor02/Minecraft-But
        private void ImageEffects_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ImageEffects.SelectedItem != null)
            {
                process.Add(effectList[ImageEffects.SelectedIndex]);
                HistoryTextBox.Items.Add(ImageEffects.SelectedItem + "");


                preview = new Bitmap(Effects.ApplyEffect(preview, effectList[ImageEffects.SelectedIndex].fileInfo));
                previewProg.Add(preview);
                PreviewPanel.BackgroundImage = Effects.ResizeImage(preview, 100, 100);

                ImageEffects.ClearSelected();
            }
        }
예제 #27
0
    public static void Blit(RenderTexture source, Rect sourceRect, RenderTexture dest, Rect destRect, BlendMode blendMode)
    {
        RenderTexture.set_active(dest);
        source.SetGlobalShaderProperty("__RenderTex");
        GL.PushMatrix();
        GL.LoadOrtho();
        Material blitMaterial = ImageEffects.GetBlitMaterial(blendMode);

        for (int i = 0; i < blitMaterial.get_passCount(); i++)
        {
            blitMaterial.SetPass(i);
            ImageEffects.DrawQuad();
        }
        GL.PopMatrix();
    }
예제 #28
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;
        }
    }
예제 #29
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);
    }
예제 #30
0
파일: Tool.cs 프로젝트: Jor02/Minecraft-But
        private void Tool_Load(object sender, EventArgs e)
        {
            //Set Fonts
            ImageEffects.Font             = McFont;
            HistoryTextBox.Font           = McFont;
            EffectsLabel.Font             = McFont;
            HistoryLabel.Font             = McFont;
            PreviewLabel.Font             = McFont;
            versionToolStripMenuItem.Font = McFont;


            foreach (ToolStripMenuItem item in ToolMainMenuStrip.Items)
            {
                item.Font = McFont;
            }


            //Effects
            ImageEffects.BeginUpdate();
            String path = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + @"\plugins\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            FileInfo[] effects = new DirectoryInfo(path).GetFiles("*.lua");
            effectList = new List <Effect>();
            foreach (FileInfo effect in effects)
            {
                Script lua = new Script();
                try
                {
                    lua.DoFile(effect.FullName);
                    ImageEffects.Items.Add(lua.Globals["name"]);
                    effectList.Add(new Effect(lua.Globals["name"].ToString(), effect));
                }
                catch (InterpreterException error)
                {
                    MessageBox.Show($@"Plugin {effect.Name} encountered an error:
{error.Message}", "Lua error");
                }
            }
            ImageEffects.EndUpdate();
        }
예제 #31
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);
        }