// Renders everything not opaque-only // // Current order of operation is as following: // 1. Pre-stack // 2. Built-in stack // 3. Post-stack // 4. Built-in final pass // // Final pass should be skipped when outputting to a HDR display. public void Render(PostProcessRenderContext context) { if (RuntimeUtilities.scriptableRenderPipelineActive) { SetupContext(context); } TextureLerper.instance.BeginFrame(context); var cmd = context.command; // Update & override layer settings first (volume blending) if the opaque only pass // hasn't been called this frame. UpdateSettingsIfNeeded(context); // Do a NaN killing pass if needed int lastTarget = -1; if (stopNaNPropagation && !m_NaNKilled) { lastTarget = m_TargetPool.Get(); cmd.GetTemporaryRT(lastTarget, context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat); cmd.BlitFullscreenTriangle(context.source, lastTarget, RuntimeUtilities.copySheet, 1); context.source = lastTarget; m_NaNKilled = true; } // Do temporal anti-aliasing first if (context.IsTemporalAntialiasingActive()) { if (!RuntimeUtilities.scriptableRenderPipelineActive) { if (XRSettings.isDeviceActive) { // We only need to configure all of this once for stereo, during OnPreCull if (context.camera.stereoActiveEye != Camera.MonoOrStereoscopicEye.Right) { temporalAntialiasing.ConfigureStereoJitteredProjectionMatrices(context); } } else { temporalAntialiasing.ConfigureJitteredProjectionMatrix(context); } } var taaTarget = m_TargetPool.Get(); var finalDestination = context.destination; cmd.GetTemporaryRT(taaTarget, context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat); context.destination = taaTarget; temporalAntialiasing.Render(context); context.source = taaTarget; context.destination = finalDestination; if (lastTarget > -1) { cmd.ReleaseTemporaryRT(lastTarget); } lastTarget = taaTarget; } bool hasBeforeStackEffects = HasActiveEffects(PostProcessEvent.BeforeStack, context); bool hasAfterStackEffects = HasActiveEffects(PostProcessEvent.AfterStack, context) && !breakBeforeColorGrading; bool needsFinalPass = (hasAfterStackEffects || (antialiasingMode == Antialiasing.FastApproximateAntialiasing) || (antialiasingMode == Antialiasing.SubpixelMorphologicalAntialiasing && subpixelMorphologicalAntialiasing.IsSupported())) && !breakBeforeColorGrading; // Right before the builtin stack if (hasBeforeStackEffects) { lastTarget = RenderInjectionPoint(PostProcessEvent.BeforeStack, context, "BeforeStack", lastTarget); } // Builtin stack lastTarget = RenderBuiltins(context, !needsFinalPass, lastTarget); // After the builtin stack but before the final pass (before FXAA & Dithering) if (hasAfterStackEffects) { lastTarget = RenderInjectionPoint(PostProcessEvent.AfterStack, context, "AfterStack", lastTarget); } // And close with the final pass if (needsFinalPass) { RenderFinalPass(context, lastTarget); } // Render debug monitors & overlay if requested debugLayer.RenderSpecialOverlays(context); debugLayer.RenderMonitors(context); // End frame cleanup TextureLerper.instance.EndFrame(); debugLayer.EndFrame(); m_SettingsUpdateNeeded = true; m_NaNKilled = false; }
public void Render(PostProcessRenderContext context) { if (RuntimeUtilities.scriptableRenderPipelineActive) { SetupContext(context); } TextureLerper.instance.BeginFrame(context); CommandBuffer command = context.command; UpdateSettingsIfNeeded(context); int num = -1; if (stopNaNPropagation && !m_NaNKilled) { num = m_TargetPool.Get(); context.GetScreenSpaceTemporaryRT(command, num, 0, context.sourceFormat); command.BlitFullscreenTriangle(context.source, num, RuntimeUtilities.copySheet, 1); context.source = num; m_NaNKilled = true; } if (context.IsTemporalAntialiasingActive()) { if (!RuntimeUtilities.scriptableRenderPipelineActive) { if (context.stereoActive) { if (context.camera.stereoActiveEye != Camera.MonoOrStereoscopicEye.Right) { temporalAntialiasing.ConfigureStereoJitteredProjectionMatrices(context); } } else { temporalAntialiasing.ConfigureJitteredProjectionMatrix(context); } } int num2 = m_TargetPool.Get(); RenderTargetIdentifier destination = context.destination; context.GetScreenSpaceTemporaryRT(command, num2, 0, context.sourceFormat); context.destination = num2; temporalAntialiasing.Render(context); context.source = num2; context.destination = destination; if (num > -1) { command.ReleaseTemporaryRT(num); } num = num2; } bool flag = HasActiveEffects(PostProcessEvent.BeforeStack, context); bool flag2 = HasActiveEffects(PostProcessEvent.AfterStack, context) && !breakBeforeColorGrading; bool flag3 = (flag2 || antialiasingMode == Antialiasing.FastApproximateAntialiasing || (antialiasingMode == Antialiasing.SubpixelMorphologicalAntialiasing && subpixelMorphologicalAntialiasing.IsSupported())) && !breakBeforeColorGrading; if (flag) { num = RenderInjectionPoint(PostProcessEvent.BeforeStack, context, "BeforeStack", num); } num = RenderBuiltins(context, !flag3, num); if (flag2) { num = RenderInjectionPoint(PostProcessEvent.AfterStack, context, "AfterStack", num); } if (flag3) { RenderFinalPass(context, num); } debugLayer.RenderSpecialOverlays(context); debugLayer.RenderMonitors(context); TextureLerper.instance.EndFrame(); debugLayer.EndFrame(); m_SettingsUpdateNeeded = true; m_NaNKilled = false; }