I wrote a script that saves a render texture to a .png.
However, the results are not very good, the .png is always much darker than the Render texture is in Unity. How can I fix this so that there is no attempt at color correction?
Script:
[SerializeField]
RenderTexture rt;
[SerializeField]
string fileName;
[Button("Save png")]
public void SavePNG()
{
var tex = new Texture2D(rt.width, rt.height);
RenderTexture.active = rt;
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
tex.Apply();
var path = "Assets/Textures/Rendered textures/" + fileName + ".png";
File.WriteAllBytes(path, tex.EncodeToPNG());
Debug.Log("Saved file to: " + path);
}