Using UDK's material editor, I wish to use a texture as a two-dimensional array of values for mathematical computations (basically, the color components of each pixel in the texture alter the behavior of some transformations applied to another texture).
I want to retain rather precise color values for my mathematical operations to keep their meaning, but in my experiments I noticed a heavy distortion of the color space: dark colors are darker than they should be, and light colors are lighter than they should.
This effect is best shown by the following material, which takes a simple linear gradient texture, and applies a rounding operation on the colors:
If the colors were correctly preserved, the preview on the left should have 10 bands of equal length (a black band, a 10% gray band, a 20% gray band etc. with each band being 10% of the width of the image), however the black band is huge, the next (10% gray) one rather large, and the bands get smaller and smaller as they get lighter.
In this example, I take the red channel of the image, but taking the other channels gives similar results: The red and blue channels are identical, and the distortion is slightly different with the green channel, and taking the combination of these logically produces small bands of purple and green between any two bands.
I guess this is a compression issue with the original texure, but I don't know which parameters I should change so the colors are preserved when I use the texture in the material editor.
Above is the texture I used, created with The Gimp. The colors are correct, it is a linear gradient: the color of the pixels in column 0 is (0,0,0), the pixels in the column 255 are (255,255,255) and I manually checked at many points in the image that the pixels in the column x are (x,x,x)).
Above are the properties for this texture. Nothing special here, just the defaults. Specifically, the
Adjust Brightness Curve and
Adjust RGB Curve properties are set to
1.0 (by default), which seems correct since they are the power to which the HSV and RGB curves must be elevated. The distortion I observed looks a lot like if the values were raised to a given power.