public void Render(RenderTexture source, RenderTexture destination) { ApplyProjectionMatrices(); Material material = context.materialFactory.Get(k_ShaderString); material.shaderKeywords = null; AntialiasingModel.TaaSettings taaSettings = model.settings.taaSettings; int activeEye = (int)context.camera.stereoActiveEye % k_NumEyes; int pp = m_HistoryPingPong[activeEye]; var historyRead = CheckHistory(activeEye, ++pp % k_NumEyes, source, material); var historyWrite = CheckHistory(activeEye, ++pp % k_NumEyes, source, material); m_HistoryPingPong[activeEye] = ++pp % k_NumEyes; material.SetVector(Uniforms._Jitter, jitterVector); material.SetVector(Uniforms._SharpenParameters, new Vector4(m_sharpenOverride ?? taaSettings.sharpen, 0f, 0f, 0f)); material.SetVector(Uniforms._FinalBlendParameters, new Vector4(taaSettings.stationaryBlending, taaSettings.motionBlending, 6000f, 0f)); material.SetTexture(Uniforms._MainTex, source); material.SetTexture(Uniforms._HistoryTex, historyRead); m_Mrt[0] = destination.colorBuffer; m_Mrt[1] = historyWrite.colorBuffer; Graphics.SetRenderTarget(m_Mrt, source.depthBuffer); GraphicsUtils.Blit(material, context.camera.orthographic ? 1 : 0); m_ResetHistory = false; }
public void Render(RenderTexture source, RenderTexture destination) { var material = context.materialFactory.Get(k_ShaderString); material.shaderKeywords = null; var settings = model.settings.taaSettings; if (m_ResetHistory || m_HistoryTexture == null || m_HistoryTexture.width != source.width || m_HistoryTexture.height != source.height) { if (m_HistoryTexture) { RenderTexture.ReleaseTemporary(m_HistoryTexture); } m_HistoryTexture = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); m_HistoryTexture.name = "TAA History"; Graphics.Blit(source, m_HistoryTexture, material, 2); } const float kMotionAmplification = 100f * 60f; material.SetVector(Uniforms._SharpenParameters, new Vector4(settings.sharpen, 0f, 0f, 0f)); material.SetVector(Uniforms._FinalBlendParameters, new Vector4(settings.stationaryBlending, settings.motionBlending, kMotionAmplification, 0f)); material.SetTexture(Uniforms._MainTex, source); material.SetTexture(Uniforms._HistoryTex, m_HistoryTexture); var tempHistory = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); tempHistory.name = "TAA History"; m_MRT[0] = destination.colorBuffer; m_MRT[1] = tempHistory.colorBuffer; Graphics.SetRenderTarget(m_MRT, source.depthBuffer); GraphicsUtils.Blit(material, context.camera.orthographic ? 1 : 0); RenderTexture.ReleaseTemporary(m_HistoryTexture); m_HistoryTexture = tempHistory; m_ResetHistory = false; }