Why does a Texture2D is being initialized with all colors set to (1, 1, 1, 0.84)?

Hello everyone,

I’m initializing a Texture2D of 512x512 a few times per frame. I noticed some areas were getting transparent and I assumed the texture was 100% opaque white. Then I tried to print the value for a pixel and I got (1,1,1,0.84) which is white with a bit of transparency but I don’t want that. I wanted the constructor to set all pixels to (1,1,1,1).

I really don’t want to use SetPixels passing a 512x512 array of white colors nor loop through the whole texture setting each colour to (1,1,1,1).

A solution would be to hold a 32x32 (example) array of white color and loop through the texture a few times using SetPixels, but if I could I would like to avoid this kind of computation as much as possible.

My question is: Why is the texture being initialized with 0.84 as the alpha value? And is there a way to initialize it with all parameters being 1?

PS: I’m using Alpha8 as my texture format. If I switch for, let’s say, RGBA32, all the colours are initialized with 0.84 as their values.

Thank you very much!

The documentation doesn’t say what it fills with, which means it’s undefined. So, it may not even be that 0.84 on other platforms; it may just be memory garbage. The doc also says you want to set the pixels after you create it.

If you always want to set them to white, you can just keep a single array of 512x512 white colors, and apply that single array to each new texture without instantiating a new one each time.

On a separate note, why are you instantiating new big white textures a few times a frame? That’s incredibly memory inefficient, and if they’re all the same white, then they can be shared.