- Home /
Inverse of a texture for masking?
Hey, I was wondering how you can get the inverse of a texture? Like in photoshop when you have a grayscale image you can make the white values black and the black values white. I need this because I'm generating a texture during runtime with my kinect and want the inverse of this image for masking.
I've got the mask working, but it's masking everything that is black and I need it the other way arround.
so I thought the easiest way was the inverse of my texture. If you have other better solutions I'm all ears aswell :D
$$anonymous$$aybe what you found is a 1-off that only works for your exact situation. But if you solved this in a way that seems like it might help someone else, why not post it, or add a link (if it was the result of a tricky search.)
Answer by Owen-Reynolds · Feb 17, 2015 at 05:02 AM
Just read the Texture2D docs: SetPixels and Apply can hand-edit however you want. All you need to know is that colors are stored 0-1 (which is pretty standard.) So can easily loop through and set each channel to 1-channel. Should be able to find lots of examples of pixel changing. Takes a bit to run, though.
But, depending on how the Mask works, should be possible to change it to Mask out white instead.
Ok, I had already found a solution on how to fix my mask. But this is useful information for the future :) so thanks a lot :)