|
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?
(comments are locked)
|
|
Try this. It just uses the minimum of the two alpha values: (oops, fixed typo in code)
Jan 21 '10 at 09:35 AM
duck ♦♦
This method applies a mask to the dest texture. I think the poster asked for a way to stamp the "mask" texture onto the dest texture, using the alpha channel of the "mask".
Jan 21 '10 at 09:50 AM
runevision ♦♦
Ah yes, I read the question as being how to punch a hole through one image, using the alpha of another image. On re-reading, I think you're correct.
Jan 21 '10 at 10:42 AM
duck ♦♦
I guess my original question wasn't so clear. The dest array is solid, so it looks like the best way to do it is the answer below. Thanks for your help anyway--Sorry I wasn't so clear!
Jan 26 '10 at 03:07 AM
thom
(comments are locked)
|
|
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! Wow! Great thank you! Looks WAY Better than it did!
Jan 26 '10 at 03:07 AM
thom
(comments are locked)
|
