FxaaComponent.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. namespace UnityEngine.PostProcessing
  3. {
  4. public sealed class FxaaComponent : PostProcessingComponentRenderTexture<AntialiasingModel>
  5. {
  6. public override bool active
  7. {
  8. get
  9. {
  10. return base.model.enabled && base.model.settings.method == AntialiasingModel.Method.Fxaa && !this.context.interrupted;
  11. }
  12. }
  13. public void Render(RenderTexture source, RenderTexture destination)
  14. {
  15. AntialiasingModel.FxaaSettings fxaaSettings = base.model.settings.fxaaSettings;
  16. Material material = this.context.materialFactory.Get("Hidden/Post FX/FXAA");
  17. AntialiasingModel.FxaaQualitySettings fxaaQualitySettings = AntialiasingModel.FxaaQualitySettings.presets[(int)fxaaSettings.preset];
  18. AntialiasingModel.FxaaConsoleSettings fxaaConsoleSettings = AntialiasingModel.FxaaConsoleSettings.presets[(int)fxaaSettings.preset];
  19. material.SetVector(FxaaComponent.Uniforms._QualitySettings, new Vector3(fxaaQualitySettings.subpixelAliasingRemovalAmount, fxaaQualitySettings.edgeDetectionThreshold, fxaaQualitySettings.minimumRequiredLuminance));
  20. material.SetVector(FxaaComponent.Uniforms._ConsoleSettings, new Vector4(fxaaConsoleSettings.subpixelSpreadAmount, fxaaConsoleSettings.edgeSharpnessAmount, fxaaConsoleSettings.edgeDetectionThreshold, fxaaConsoleSettings.minimumRequiredLuminance));
  21. Graphics.Blit(source, destination, material, 0);
  22. }
  23. private static class Uniforms
  24. {
  25. internal static readonly int _QualitySettings = Shader.PropertyToID("_QualitySettings");
  26. internal static readonly int _ConsoleSettings = Shader.PropertyToID("_ConsoleSettings");
  27. }
  28. }
  29. }