I have a camera in my scene that is being used to render a flow map in real time. The camera renders certain particles where the particle color encodes a direction.
Everything works fine in gamma space, but in linear space, the gamma->linear conversions are breaking everything.
According to the documentation about render textures, I should be able to set the RenderTextureReadWrite mode of my camera’s render texture to Linear to avoid these conversions, even though the project is set to linear space:
“However, if your render texture will contain non-color data (normals, velocities, other custom values) then you don’t want Linear<->sRGB conversions to happen. This is the Linear read-write mode.”
Unfortunately, none of the values of that enum appear to change anything. What am I doing wrong?
I have also tried setting GL.sRGBWrite in OnPreRender and setting it back in OnPostRender, but that doesn’t do anything either (yes, the script with OnPreRender and OnPostRender is attached to my camera). Does that variable only work if you are rendering using the GL API, but not general Cameras?
I never got it to work using the setting on the render texture. So I ended up having to work around it by converting between linear and gamma space in the shaders and doing conversions on colors passed to the shaders. Kind of unfortunate that we have to pay the performance cost of these redundant calculations.
I got this working (at least for my requirements).
The documentation notes: “Note that some render texture formats are always considered to contain “linear” data and no sRGB conversions are ever performed on them, no matter what is the read-write setting. This is true for all “HDR” (floating point) formats, and other formats like Depth or Shadowmap.”
So, when using the RenderTexture constructor, I used the RenderTextureFormat.ARGB32 and RenderTextureReadWrite.Linear parameters. That seemed to do the trick for me.
Bumping because this is the first thread on Google.
For render textures created as assets in the project folder, you can set your inspector to Debug Mode and toggle the SRGB setting there. This was the only thing that worked for me.