- Home /
Unwanted dark edge around RenderTexture
Using the code below i'm taking a screenshot of a designated area using a rendertexture, and saving it as a PNG. Unfortunately no matter what i do i keep getting dark edges that are 1 pixel wide. Somtimes it's on the bottom, and sometimes it's on the bottom and left. Depends on what resolution i save the image.
My camera settings are Depth only and Orthographic. The size varies depending on the device aspect ratio, but it doesn't seem to matter
Anyone ever get this problem when using rendertextures?
here's the problem illustrated-
void OnPostRender(){
if(takePic){
Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false);
RenderTexture rtTemp = RenderTexture.GetTemporary (width, height, 0, 0,RenderTextureReadWrite.Default);
cam.targetTexture = rtTemp;
RenderTexture.active = rtTemp;
tex.ReadPixels (new Rect(0, 0, width, height), 0, 0);
tex.Apply ();
byte[] bytes = tex.EncodeToPNG();
Destroy (tex);
string pngfilepath = MenuManager.screenShotDataPath + MenuManager.currentScreen + @".png";
File.WriteAllBytes(pngfilepath, bytes);
RenderTexture.ReleaseTemporary (rtTemp);
takePic = false;
gameObject.SetActive(false);
}
}
Your answer
Follow this Question
Related Questions
How can I copy an ARGBHalf RenderTexture to a Texture2D on Windows? 0 Answers
Best way to access RenderTexture immediately after camera render 0 Answers
RenderTexture turn my model to black, why ? 1 Answer
Can a Texture2D be created at runtime from a snapshot of a RenderTexture? 3 Answers
How do I get the raw pixels of a RFloat RenderTexture on the CPU? 5 Answers