1
\$\begingroup\$

I'm working on a transition effect where I have a texture and simply draw that as a pattern to my buffer. Here is a demo, use "e" to start the effect again. This looks fine but it won't work if the texture has pixels with alpha 0 < x < 1.

This is the texture I used in my demo ( zoomed ):

enter image description here

As you can see the edges are rough and full on opaque. If I do use a texture with softer edges the pixels with alpha will just smear the black away. How can I achieve the effect of pixels in my texture with an alpha of 0 < x 1 to only affect pixels with alpha 0 in my buffer?

\$\endgroup\$
  • \$\begingroup\$ Do I understand it right - you wish the circle smooth, however you do not like it gets darkened on the edges? \$\endgroup\$ – wondra Sep 6 '14 at 16:37
  • \$\begingroup\$ I do want the option for smooth edges ( so any texture can be substituted without resorting to removing soft pixels). The problem is , for example, once 2 of these circles overlap the alpha in the edges replace the black and cause an ugly alpha effect. Ill update with a picture. \$\endgroup\$ – Sidar Sep 6 '14 at 16:43
  • \$\begingroup\$ Well this is awkward...Apparently I already fixed it after discovering the problem. Blending : BlendingOperation.SourceAlpha, BlendingOperation.DestinationAlpha did the trick apparently. I had this issue a while now but have only been working with hard edges. So I had no idea my problem was already solved. ACK! \$\endgroup\$ – Sidar Sep 6 '14 at 16:49
0
\$\begingroup\$

( If it's more appropriate to remove this thread please let me know)

When the problem occurred I changed to hard edges and only worked with that. Meanwhile I changed my drawing logic and the fix went unnoticed:

The problem was that I didn't have the right blending modes applied, these should work. ( names might be slightly different in OpenGL) This is done in Kha and Haxe:

//before rendering fading **in** blend modes : 
g2.setBlendingMode(BlendingOperation.DestinationAlpha, BlendingOperation.SourceAlpha);
//bedore rendering fading **out** blend modes :                 
g2.setBlendingMode(BlendingOperation.SourceAlpha, BlendingOperation.DestinationAlpha);

If someone has some pointers, that would be appreciated.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.