Image effect shader not running

I created an image effect shader for the camera that is supposed to pixelate the screen but no matter what I do it’s not running / working.

I am using Unity version 2019.3.6f1 with URP installed.

I noticed that the shader (and other similar ones) are not working anymore after installing URP

Does OnRenderImage() work with URP?

Shader "Hidden/Pixelated"
		_MainTex("Texture", 2D) = "white" {}
		_ScreenWidth("screen width", float) = 320.0
		_ScreenHeight("screen height", float) = 240.0
		_CellSizeX("size of x cell", float) = 4.0
		_CellSizeY("size of y cell", float) = 4.0
			// No culling or depth
			Cull Off ZWrite Off ZTest Always

				#pragma vertex vert
				#pragma fragment frag

				#include "UnityCG.cginc"

				struct appdata
					float4 vertex : POSITION;
					float2 uv : TEXCOORD0;

				struct v2f
					float2 uv : TEXCOORD0;
					float4 vertex : SV_POSITION;

				v2f vert(appdata v)
					v2f o;
					o.vertex = UnityObjectToClipPos(v.vertex);
					o.uv = v.uv;
					return o;

				sampler2D _MainTex;
				float _ScreenWidth;
				float _ScreenHeight;
				float _CellSizeX;
				float _CellSizeY;

				fixed4 frag(v2f i) : SV_Target
					float2 uv = i.uv;

					float pixelX = _ScreenWidth / _CellSizeX;
					float pixelY = _ScreenHeight / _CellSizeY;

					return tex2D(_MainTex, float2(floor(pixelX * uv.x) / pixelX, floor(pixelY * uv.y) / pixelY));

And this is the script that’s attached to the main camera
using UnityEngine;

public class PostProcess : MonoBehaviour
    private Vector2 cellSize = new Vector2(4, 4);

    private Material material;

    private void Awake()
        material = new Material(Shader.Find("Hidden/Pixelated"));

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
        material.SetFloat("_ScreenWidth", Screen.width);
        material.SetFloat("_ScreenHeight", Screen.height);
        material.SetFloat("_CellSizeX", cellSize.x);
        material.SetFloat("_CellSizeY", cellSize.y);
        Graphics.Blit(source, destination, material);

The result is always as if no shader was applied even when changing the fragment function return to return fixed4(1, 0, 0, 1); which should return a red screen if I am not wrong.

Adding the shader in the “Always included shaders” list did not solve the problem (Edit->Project Settings->Graphics)

Image effects need to be drawn at a specific part of the rendering process. OnRenderImage was called by the built-in pipeline as a way of injecting custom post-processing at the correct point, but because SRP’s handle all rendering manually, they would also need to manually call the method. In theory you can do this, however Unity’s SRPs use their own post-processing stacks that are called directly by the rendering pipeline. HDRP has support for custom effect injection, but as of now URP does not. If you wanted to use custom post-processing in URP, you would need to modify the internal renderer to also draw your custom effects. Here are some links to the files that handle post-processing, so you can probably copy and modify some of the built-in effects to do what you need.

Another thing to keep in mind is that the shader-side approach to writing image effects has changed a bit. Here’s the Unity guide to writing post-processing for the stack (and for future pipelines);