I want to have a pixel-perfect 2d game. I’ve written a compute shader that writes color information to a RenderTexture. The next step is to render it on screen. I’ve tried a few things like rendering to a quad and having a camera pick it up. I would like to have a 1:1 between screen pixels and the pixels in the RenderTexture so I have created a small RenderingPipeline.
public class PixelRenderingPipeline : RenderPipeline
{
public static RenderTexture active;
protected override void Render(ScriptableRenderContext context, Camera[] cameras)
{
var cmd = new CommandBuffer();
cmd.ClearRenderTarget(true, true, Color.black);
context.ExecuteCommandBuffer(cmd);
cmd.Release();
context.Submit();
if (active == null) return;
Graphics.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), active);
}
}
This “works” but I am wondering if there is a better way to do this. Perhaps a method on the CommandBuffer? I want to be able to write shaders that do post-processing effects as well.