Hello everyone,
i’m trying to take a set of high resolution (at least 2560 x 1440) screenshots using a RenderTexture, and temporal anti-aliasing in an HDRP project.
Capturing with fast AA works, but the image quality is not good enough.
With Temporal AA if the screenshot’s size is exactly the size of the game window, it works.
In any larger resolution the images somehow stacking on each other. And a small picture appears on the lower left corner. The size of the small one is exactly ImageHeight/Y * ImageWidth/X.
public void Capture(int X, int Y, string ImageName)
{
int ResWidth = Screen.width * X;
int ResHeight = Screen.height * Y;
Texture2D shot = new Texture2D(ResWidth, ResHeight);
RenderTexture rt = new RenderTexture(ResWidth, ResHeight, 32);
Camera.main.GetComponent<Camera>().targetTexture = rt;
RenderTexture.active = rt;
TakeScreenShot(X, Y, out shot);
RenderTexture.active = null;
DestroyImmediate(rt);
SaveFile(shot, ImageName);
DestroyImmediate(shot);
}
void TakeScreenShot(int ResWidth, int ResHeight, out Texture2D shot)
{
Texture2D tempTexture = new Texture2D(ResWidth, ResHeight, TextureFormat.ARGB32, false);
Camera.main.GetComponent<Camera>().Render();
tempTexture.ReadPixels(new Rect(0, 0, ResWidth, ResHeight), 0, 0);
shot = tempTexture;
}
I’m stuck on this for days, pulling my hair out… Any help is appreciated.