I have been writing some custom effects for the post-processing stack for my game. The custom effects guide says that you can order your effects per post-processing layer, which I have done, and that built-in effects are ordered automatically. However, I want to be able to change the order of all the post-processing effects, so that one of my custom effects can be run before or in-between the built-in Unity effects. Surely this has to be pretty easy, but I can’t find where Unity has opened it up to let you change the default order. I think I could accomplish what I want with CommandBuffers, but I’m not as familiar with the post-processing stack as I am with other parts of Unity so I don’t want to mess with it and risk it breaking down the line.
I suppose a workaround could be to copy Unity’s effect(s) or write my own and use it as a custom effect instead of the default one, but that sounds horrendously unconventional.
Apologies if this is something simple that I have just overlooked. Took me a while to find custom effect sorting even though it was just under my nose on the PP layer.
Did you find a solution?
I have also written a selective custom effect and I am wondering how to manipulate with its order.
The custom effect template does not seem to provide an option to set an order variable, even with a limited options (BeforeStack, BeforeTransparent and AfterStack).
using System;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
[Serializable]
[PostProcess(typeof(GrayscaleRenderer), PostProcessEvent.AfterStack, "Custom/Grayscale")]
public sealed class Grayscale : PostProcessEffectSettings
{
[Range(0f, 1f), Tooltip("Grayscale effect intensity.")]
public FloatParameter blend = new FloatParameter { value = 0.5f };
}
public sealed class GrayscaleRenderer : PostProcessEffectRenderer<Grayscale>
{
public override void Render(PostProcessRenderContext context)
{
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/Grayscale"));
sheet.properties.SetFloat("_Blend", settings.blend);
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
}
}