Creating a deferred SRP using Unity's examples

I’d like to make my own deferred SRP, currently trying to recreate the example renderer given here Unity - Scripting API: Rendering.ScriptableRenderContext.BeginScopedRenderPass, minus whatever they have conveniently left out in the RenderGBuffer, RenderLighting, and FinalPass functions.

The rest of my SRP is more or less the boilerplate SRP code from catlike coding’s tuts: https://bitbucket.org/catlikecodingunitytutorials/custom-srp-01-custom-render-pipeline/src/master/

Currently unity is throwing ‘RenderPass: Attachment dimensions or sample count do not match RenderPass specifications (886 x 433 1AA) vs (884 x 391 1AA)’ at me whenever it tries to render anything. Really confused as to what’s causing this.

Same for me. I get this error only when using SceneView, so it’s better to file a bug and don’t care about that for now.

BTW if you make resolutions match, SceneView will stop rendering completely and complain about missmatch color/depth resolution.

Thats the fix. Reason - for scene view Unity is using RenderTexture.

            int width = camera.scaledPixelWidth;
            int height = camera.scaledPixelHeight;
            int aa = 1;
            RenderTargetIdentifier target = BuiltinRenderTextureType.CameraTarget;

            if (camera.targetTexture)
            {
                width = camera.targetTexture.width;
                height = camera.targetTexture.height;
                target = camera.targetTexture;
                aa = camera.targetTexture.antiAliasing;
            }

            var depth = new AttachmentDescriptor(RenderTextureFormat.Depth);
            var screen = new AttachmentDescriptor(RenderTextureFormat.Default);
            screen.ConfigureTarget(target, false, true);

            var albedo = new AttachmentDescriptor(RenderTextureFormat.ARGB32);
            var normals = new AttachmentDescriptor(RenderTextureFormat.ARGBHalf);

            _attachments = new NativeArray<AttachmentDescriptor>(4, Allocator.Temp);
            _attachments[0] = depth;
            _attachments[1] = screen;
            _attachments[2] = albedo;
            _attachments[3] = normals;

            ctx.BeginRenderPass(width, height, aa, _attachments, 0);
1 Like