I’m trying to plug in a data from blender that is supposed to be processed as linear colorspace.
To be precise, the data in question is baked depth information mapped to a range.
The problem is:
BLender only saves linear images as OpenEXR format and currently Unity’s openexr support appears to be broken. To be specific, OpenEXR images correctly display in inspector preview, but the moment I plug them into a material, I’m getting junk data. (I reported a bug regarding this issue: Case 952548 )
I’m currently trying to write a mini converter in python, but it looks like the OpenEXR library for python only supports Python 3 and not Python 2.7. Aaand of course image converters apply gamma correction when I convert between exr and png.
Has anyone dealt with something like this? I’m trying to find a sane way to deal with nonsense.
It is possible to export linear data from blender via openexr.
OpenEXRSharp doesn’t work. Python version of OpenEXR doesn’t work (doesn’t support python 3 and fails to install on windows on python2). What does work is reading OpenEXR file using opencv bindings for python.
However, OpenCV EXR reader does not read alpha channel.
So what I did was mapping alpha to green channel in blender, exporting resulting file as OpenEXR, then reading it with python script via OpenCV and saving resulting file using Pillow. This is the only way to transfer the image into unity without it getting butchered via gamma mapping.
It also might be possible to preprocess values on blender side in order to cancel effect of gamma mapping.
If anyone knows a saner way of dealing with this, I’m listening.
I’ve received a PM regarding this post, so I’m adding additional data.
Here’s a more recent post from me regarding the situation:
As of now the situation goes like this.
If you save non-color data as anything that is not OpenEXR, it is going to have gamme curve applied to it. That applies to png, tga, jpg, etc. Meaning if you save non-color data for unity, the result will look wrong.
Blender won’t apply gamma curve to any *.exr file.
It will export alpha channel.
However, unity has a bug where it won’t import alpha channel unless you force target texture format to ARGB32 or something similar.
If you’re fine with your textures being uncompressed in memory, the current working solution to use linear colorspace is to force texture format to uncompressed ARGB upon import. Actually jsut setting it to uncompressed should suffice.