Exemplo n.º 1
0
    private void OnPostRender()
    {
        bool flag = this.QualityLevel != this.m_qualityLevel;

        if (flag)
        {
            this.CreateMaterials();
            this.m_qualityLevel = this.QualityLevel;
        }
        this.UpdateRenderTextures(flag);
        this.ResetObjectId();
        bool  flag2      = this.CameraMotionMult > 1.401298E-45f;
        bool  clearColor = !flag2 || this.m_starting;
        float y          = (this.DepthThreshold <= 1.401298E-45f) ? 3.40282347E+38f : (1f / this.DepthThreshold);

        this.m_motionScaleNorm      = ((this.m_deltaTime < 1.401298E-45f) ? 0f : (this.MotionScale * (1f / this.m_deltaTime)));
        this.m_fixedMotionScaleNorm = ((this.m_fixedDeltaTime < 1.401298E-45f) ? 0f : (this.MotionScale * (1f / this.m_fixedDeltaTime)));
        float scale      = this.m_starting ? 0f : this.m_motionScaleNorm;
        float fixedScale = this.m_starting ? 0f : this.m_fixedMotionScaleNorm;

        AmplifyMotionEffectBase.DiscardContents(this.m_motionRT);
        this.m_updateCB.Clear();
        this.m_renderCB.Clear();
        this.m_renderCB.SetGlobalFloat("_AM_MIN_VELOCITY", this.MinVelocity);
        this.m_renderCB.SetGlobalFloat("_AM_MAX_VELOCITY", this.MaxVelocity);
        this.m_renderCB.SetGlobalFloat("_AM_RCP_TOTAL_VELOCITY", 1f / (this.MaxVelocity - this.MinVelocity));
        this.m_renderCB.SetGlobalVector("_AM_DEPTH_THRESHOLD", new Vector2(this.DepthThreshold, y));
        this.m_renderCB.SetRenderTarget(this.m_motionRT);
        this.m_renderCB.ClearRenderTarget(true, clearColor, Color.black);
        if (flag2)
        {
            float num    = (this.m_deltaTime < 1.401298E-45f) ? 0f : (this.MotionScale * this.CameraMotionMult * (1f / this.m_deltaTime));
            float scale2 = this.m_starting ? 0f : num;
            this.RenderReprojectionVectors(this.m_renderCB, this.m_motionRT, scale2);
        }
        this.m_baseCamera.RenderVectors(this.m_renderCB, scale, fixedScale, this.QualityLevel);
        for (int i = 0; i < this.m_linkedCameraValues.Length; i++)
        {
            AmplifyMotionCamera amplifyMotionCamera = this.m_linkedCameraValues[i];
            if (amplifyMotionCamera != null && amplifyMotionCamera.Overlay && amplifyMotionCamera.isActiveAndEnabled)
            {
                this.m_linkedCameraValues[i].RenderVectors(this.m_renderCB, scale, fixedScale, this.QualityLevel);
            }
        }
        this.m_starting = false;
    }
Exemplo n.º 2
0
        private void UpdateVerticesGPU(CommandBuffer updateCB, bool starting)
        {
            if (!starting && this.m_wasVisible)
            {
                AmplifyMotionEffectBase.DiscardContents(this.m_gpuPrevVertices);
                updateCB.Blit(new RenderTargetIdentifier(this.m_gpuCurrVertices), this.m_gpuPrevVertices);
            }
            updateCB.SetGlobalMatrix("_AM_WORLD_TO_LOCAL_MATRIX", this.m_worldToLocalMatrix);
            AmplifyMotionEffectBase.DiscardContents(this.m_gpuCurrVertices);
            RenderTexture rt = null;

            updateCB.Blit(new RenderTargetIdentifier(rt), this.m_gpuCurrVertices, this.m_gpuSkinDeformMat, Mathf.Min(this.m_weightCount - 1, 2));
            if (starting || !this.m_wasVisible)
            {
                AmplifyMotionEffectBase.DiscardContents(this.m_gpuPrevVertices);
                updateCB.Blit(new RenderTargetIdentifier(this.m_gpuCurrVertices), this.m_gpuPrevVertices);
            }
        }
Exemplo n.º 3
0
    private void ApplyMotionBlur(RenderTexture source, RenderTexture destination, Vector4 blurStep)
    {
        bool          flag          = this.QualityLevel == Quality.Mobile;
        int           qualityLevel  = (int)this.QualityLevel;
        RenderTexture renderTexture = null;

        if (flag)
        {
            renderTexture            = RenderTexture.GetTemporary(this.m_width, this.m_height, 0, RenderTextureFormat.ARGB32);
            renderTexture.name       = "AM-DepthTemp";
            renderTexture.wrapMode   = TextureWrapMode.Clamp;
            renderTexture.filterMode = FilterMode.Point;
        }
        RenderTexture temporary = RenderTexture.GetTemporary(this.m_width, this.m_height, 0, source.format);

        temporary.name       = "AM-CombinedTemp";
        temporary.wrapMode   = TextureWrapMode.Clamp;
        temporary.filterMode = FilterMode.Point;
        AmplifyMotionEffectBase.DiscardContents(temporary);
        this.m_combineMaterial.SetTexture("_MotionTex", this.m_motionRT);
        source.filterMode = FilterMode.Point;
        Graphics.Blit(source, temporary, this.m_combineMaterial, 0);
        this.m_blurMaterial.SetTexture("_MotionTex", this.m_motionRT);
        if (flag)
        {
            Graphics.Blit(null, renderTexture, this.m_depthMaterial, 0);
            this.m_blurMaterial.SetTexture("_DepthTex", renderTexture);
        }
        if (this.QualitySteps > 1)
        {
            RenderTexture temporary2 = RenderTexture.GetTemporary(this.m_width, this.m_height, 0, source.format);
            temporary2.name       = "AM-CombinedTemp2";
            temporary2.filterMode = FilterMode.Point;
            float         num            = 1f / (float)this.QualitySteps;
            float         num2           = 1f;
            RenderTexture renderTexture2 = temporary;
            RenderTexture renderTexture3 = temporary2;
            for (int i = 0; i < this.QualitySteps; i++)
            {
                if (renderTexture3 != destination)
                {
                    AmplifyMotionEffectBase.DiscardContents(renderTexture3);
                }
                this.m_blurMaterial.SetVector("_AM_BLUR_STEP", blurStep * num2);
                Graphics.Blit(renderTexture2, renderTexture3, this.m_blurMaterial, qualityLevel);
                if (i < this.QualitySteps - 2)
                {
                    RenderTexture renderTexture4 = renderTexture3;
                    renderTexture3 = renderTexture2;
                    renderTexture2 = renderTexture4;
                }
                else
                {
                    renderTexture2 = renderTexture3;
                    renderTexture3 = destination;
                }
                num2 -= num;
            }
            RenderTexture.ReleaseTemporary(temporary2);
        }
        else
        {
            this.m_blurMaterial.SetVector("_AM_BLUR_STEP", blurStep);
            Graphics.Blit(temporary, destination, this.m_blurMaterial, qualityLevel);
        }
        if (flag)
        {
            this.m_combineMaterial.SetTexture("_MotionTex", this.m_motionRT);
            Graphics.Blit(source, destination, this.m_combineMaterial, 1);
        }
        RenderTexture.ReleaseTemporary(temporary);
        if (renderTexture != null)
        {
            RenderTexture.ReleaseTemporary(renderTexture);
        }
    }