I have two color Arrays and I want to add them together. One of them is a solid (dest), and the other one (mask) has an alpha cutout. I want to stamp the alpha cutout onto the solid cleanly.
What I am doing is:
[Loop all of the pixels] if( mask[ptr].a != 0) dest[ptr] = mask[ptr];
then writing it to the texture.
It works great, however the edges end up a little dirty. Anyone know a way to add these together in a true alpha stamp as it would look in photoshop?
asked Jan 21 '10 at 06:47 AM
If I understand you correctly, you want to apply a cutout texture, but with edges that are not 100% sharp. So you can use the alpha from the mask to control the strength with which it should be applied.
For each pixel you can apply the mask this way:
This way should even work for dest pixels that are not necessarily solid.
Optional: If you want to be able to control how sharp the cutout's edges should be, you need variables to control the sharpness (contrast) and where the threshold should be (usually at 0.5):
Then you can calculate the maskAlpha this way instead of the way above:
Hope that helps!