I am really struggling to get correct raw data values from an ARGBfloat render texture.
I am using the render texture to output ‘data’ values which must not be changed in any way by colorspace conversion.
I am setting the camera clear color to a specific value e.g. mid grey.
I am using Texture2D.ReadPixels to grab the render texture into a texture (RGBAFloat texture).
Then I am using either Texture2D.GetRawTextureData or tex.GetPixels to get the data into a Color array.
But there is colorspace conversion happening somewhere. I can’t tell if it’s converting the camera clear color, or whether readpixels is converting it, or getpixels.
The value I write is e.g 0.5, the value I want back is 0.5 but it’s like 0.214 or something depending on the color channel.
When in the project settings I set it to Gamma color space, I get the exact 0.5 values back.
The render texture is set to RenderTextureReadWrite.Linear and the Texture2D it reads to is also set to linear=true. But changing these have zero effect (docs confirms this for float textures).
What exactly is the method for getting correct unchanged float data out of the render texture into a CPU color[ ] array without modifying it, and regardless of the project’s color space setting?
How can I make sure a shader or camera or whatever will output exactly the 0.5 into the render texture and then how can I get that value back out to the cpu? I don’t want any colorspace conversion to be happening anywhere, especially not in writing values to the render texture because I need to use accurate additive blending. I’ve a good mind to trash the whole thing and just do it all on the cpu.
When I try GetRawTextureData and look at the float, it’s been color-space converted, but this suggests at least I’m omitting any conversion introduced by GetPixels which is avoided. Suggest the texture actually has that value in it. But unity docs mentions “hardware” colorspace conversion relating to texture access, so I have no idea if it’s converting it on the fly.
I could apply a conversion to ‘undo’ the mess after getting the data, but this seems hacky.