- Home /
Reading Negative Values from EXR texture format
Hi All,
So I have an EXR texture file with different color values stored in each pixel. Now some of these values are negative values also (e.g. -0.03, 1, -3.123). When I try accessing these values in Unity C#, I use the Texture2D.GetPixel() method and store it in a Color datatype variable. However, when I try printing out the values from each pixel, there are no negative values. All values are clamped to between 0 and 1. When I tried Color32 datatype, the values are clamped from 0 to 255. The color values (RGB) are used for position (XYZ). So having all positive is a big issue.
It is not possible for me to normalize my pixel values to between 0 and 1 because to do so I must have a fixed minimum and a fixed maximum value. Unfortunately, the pixel values change each frame and therefore it is not possible to normalize the range. And if it is possible at all, I think it will be too costly performance wise.
Now, I am certain my EXR texture holds negative value because when I imported the texture into NUKE, the color picker in Nuke is able to show the negative vector values.
How can I go about accessing the negative values of an EXR texture/image file or any image format? I am posting this after many search on google and the forums. These are some of the posts by others having similar queries but I am not able to progress further with these...
1) http://answers.unity3d.com/questions/1220547/signed-full-precision-textures.html 2) http://answers.unity3d.com/questions/16913/reading-a-color-from-an-image.html 3) https://forum.unity3d.com/threads/negative-float-values-in-render-to-texture.199885/
I thank you guys in advance for any help rendered. I look forward to a solution that will benefit everyone who is facing similar issues.
Cheers!!
$$anonymous$$y situation is very similar to this. $$anonymous$$y texture has xyz postion data for geometry, and just like the OP has stated, only positive values are drawn.
I looked through all the above posts but none of them helped. I did find one post that said using RGBAFloat supports negative numbers, but that option doesn't exist in Unity 5.6.1 which is the version I'm on.