I’ve been experimenting with reading/writing pixel values from a UTexture2D recently, and while I’ve got my code spitting out values, they aren’t correct.
I’ve made a whole new texture in PS with red @ .75 again.
Compression: UserInterface2D(RGBA)
Texture Group: UI
SRGB = false
Still gives the exact result as the old texture .52
Im unsure what you mean by “output color set as a Linear Color” If you are talking about the lib function it is returning type FColor
When sampling through a material at a pixel and using debugscalarvalue it uses linear color as its sampler type and does return the correct value, if thats what you’re asking, but thats in a shader and the trouble is still with c++.
When casting from FColor to Linear color it seems to screw something up and return a red of .52, but when getting the byte value right from FColor on the node, it returns the original 191/255
Am I missing something about what the difference between color & linear color is? The entire spectrum appears to be shifted down a bit, like it’s being multiplied by a curve sinking function
Edit: The casting node appears to apply sRGB but doesn’t tell you. The inverse cast (LC → C) has a toggle-able boolean for weather or not it applies.
Curious to see your thoughts on this.
Bytes aren’t even in the decimal system. You’d need to calculate them and fractions in binary is a whole can of worms that I haven’t calculated since college.
It’s too late in the night for that type of torture.
With my example you get the same values in as your material.
In by conversion code the SRGB flag is copied over but I set it to true for good measures.
I believe the bytes return node there is the integer representation of the uint8, which means you can divide it by the maximum of a uint8 (256-1) to get the float representation.
I made a little tester to look between the values:
(First image was labeled backwards, sorry for the confusion)
Also take into account that Unreal’s default color workspace IS in sRGB. So any material it generates is in that color space, unless you choose otherwise in the editor preferences.
As bytes, yes, but use the node to convert them to floats and it will apply sRGB without your consent. (If you are going from FColor → FLinearColor) and mess up the final product