I have a static class that I use to build a 3d character and render the results to a RenderTarget2D which I then return.
I'd like to store the results for later use so I need to make a copy of the returned RenderTarget. To do this I`ve tried both a Quad VertexPrimitive Effect with a tiny copy PixelShaderFunction and a SpriteBatch.Draw.
I think that the Quad render is quicker but no matter how I fiddle, the Quad never seems to get it quite right.
For example, I do use SpriteBatch to pick up a 256*256 area of a large Texture2D backdrop and Draw that to a RenderTarget2D. But if I then send that directly to the Quad render and put that result back in the same place it almost - but VERY annoyingly not quite - fits back perfectly. Using another SpriteBatch.Draw does give a perfect result but I've convinced myself that it is slower.
So my questions are twofold.
1) Is the Quad UserIndexedPrimitive quicker than the SpriteBatch.Draw for multiple iterations?
2) Why can`t I get the Quad render to give me back the same image when setting it as the Effect sampler via Effect.Parameter..SetValue(RenderTarget)?
As ever, Thanks :) Stoort.
Here is the problem in png form.
The left half is the RenderTarget2D before I use a short user Effect that just does a straight copy using
return tex2D(texture, coord);
as the only PixelShaderFunction instruction via a quad with
graphicsDevice.DrawUserIndexedPrimitives<VertexPositionTexture> (PrimitiveType.TriangleList, verts, 0, 4, ib, 0, 2);
The source and destination width and height are identical as are all the RenderTarget2D settings for both.
As you can see the output on the right is blurred and the top and right lines are wrapped from the opposite sides.