Update() public method

public Update ( ) : void
return void
    // Called by camera to apply image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        angle += anglePerSecond * Time.deltaTime * Mathf.PI * 2;

        flow.Update();

        Vector3 p = new Vector3(center.position.x, center.position.y, center.position.z);

        p = GetComponent <Camera> ().WorldToViewportPoint(p);
        material.SetVector("_center", new Vector4(p.x, p.y, p.z, 0.0f));

        material.SetVector("_x", new Vector4(offset.x, offset.y, angle, fade));
        material.SetTexture("_Last", lastFrame);
        material.SetTexture("_Flow", flow.texture);
        material.SetVector("_Flow_ST", flow.scaleTranslate);

        if (radial)
        {
            Shader.EnableKeyword("radial");
            Shader.DisableKeyword("nradial");
        }
        else
        {
            Shader.EnableKeyword("nradial");
            Shader.DisableKeyword("radial");
        }
        if (invertY)
        {
            Shader.EnableKeyword("invert");
            Shader.DisableKeyword("ninvert");
        }
        else
        {
            Shader.EnableKeyword("ninvert");
            Shader.DisableKeyword("invert");
        }

        if (merge == MergeType.Add)
        {
            Shader.EnableKeyword("madd");
            Shader.DisableKeyword("mmul");
            Shader.DisableKeyword("mlerp");
        }
        else if (merge == MergeType.Mul)
        {
            Shader.EnableKeyword("mmul");
            Shader.DisableKeyword("madd");
            Shader.DisableKeyword("mlerp");
        }
        else
        {
            Shader.EnableKeyword("mlerp");
            Shader.DisableKeyword("mmul");
            Shader.DisableKeyword("madd");
        }

        Graphics.Blit(source, destination, material);
    }
Beispiel #2
0
    // Called by camera to apply image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        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;
            Graphics.Blit(source, accumTexture);
        }
        accumTexture.MarkRestoreExpected();
        angle += anglePerSecond * Time.deltaTime;

        flow.Update();
        stop.Update();

        Vector3 p = new Vector3(center.position.x, center.position.y, center.position.z);

        p = GetComponent <Camera>().WorldToViewportPoint(p);
        material.SetVector("_center", new Vector4(p.x, p.y, p.z, 0.0f));

        material.SetVector("_x", new Vector4(offset.x, offset.y, angle, fade));
        material.SetTexture("_Last", accumTexture);
        material.SetTexture("_Flow", flow.texture);
        material.SetVector("_Flow_ST", flow.scaleTranslate);
        material.SetTexture("_Stop", stop.texture);
        material.SetVector("_Stop_ST", stop.scaleTranslate);

        if (radial)
        {
            Shader.EnableKeyword("radial");
            Shader.DisableKeyword("nradial");
        }
        else
        {
            Shader.EnableKeyword("nradial");
            Shader.DisableKeyword("radial");
        }

        Graphics.Blit(source, destination, material);
        Graphics.Blit(destination, accumTexture);
    }