Question by 
               mrCharli3 · Jul 30, 2020 at 07:20 PM · 
                imagerendertexturepng  
              
 
              Saving .png from render texture results in much darker image
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);
     }
 
                 
                skarmklipp.png 
                (45.5 kB) 
               
 
              
               Comment
              
 
               
              Answer by muzboz · Aug 31, 2020 at 07:15 AM
I think you want to change the Render Texture property to "sRGB" (which is one of the properties on the Render Texture assets in the Inspector.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                