- Home /
Question by
Cynthia_ccc · May 21, 2016 at 10:51 AM ·
texture2dscreenshotlinear
Show Screenshot image on GUI, linear color space , Need help
I made a script to take screenshot and display the image on GUI. But since my project has to use linear color space, when I use the screenshot image as Texture2D on GUI, the image become dark. is there any solution for this problem?
// to capture screenshot//
Texture2D screenCap;
screenCap = new Texture2D(1024,1024, TextureFormat.RGB24, false);
screenCap.ReadPixels(new Rect(Screen.width /2 - 512, Screen.height /2 - 512 ,1024,1024), 0, 0);
screenCap.Apply();
// to see captured image void OnGUI//
GUI.DrawTexture(new Rect(100, 100, 300, 300), screenCap);
Comment
Answer by yann-papouin · Mar 17, 2017 at 11:42 AM
For the record, just switch to Debug mode if your render texture is created as an asset in the Editor. Then check the SRGB parameter.
Go back to Normal mode and change any option (eg: Color Format) to make SRGB apply.
https://docs.unity3d.com/ScriptReference/RenderTexture-sRGB.html
rt-debug.png
(17.8 kB)