Texture2D.GetPixel() returns 0.804

Hello,
So I am trying to read pixels from a texture 2d :

Texture2D texture = new Texture2D(inputDimension.x, inputDimension.y);
            Graphics.ConvertTexture(renderTextures, texture);

            for(int j = 0; j < texture.width; j++)
            {
                for(int k = 0; k < texture.height; k++)
                {
                    Debug.Log(texture.GetPixel(j, k));
                }
            }


            //mostly for debuging
            displayTexture = texture;

Now, in the inspector, displayTexture is the right texture, with colors and so.
But, the GetPixel line only return (0.804, 0.804, 0.804)
Where did i messed up ?

You have to set the RenderTexture you want to read as active (RenderTexture.active = yourRT), and then use ReadPixels to read the data.

See this for some examples and also check the manual:

1 Like

Right. If you have a look at the documentation of Graphics.ConvertTexture.

I haven’t really used ConvertTexture (haven’t even noticed when it was added) however from the documentation it seems like render textures are not supported.

Then how i can see the texture2D properly in the inspector ? where does it come from ?