Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Alpha artifacts  (Read 2691 times)

0 Members and 1 Guest are viewing this topic.

rcurtis

  • Newbie
  • *
  • Posts: 19
    • View Profile
Alpha artifacts
« on: November 10, 2014, 03:52:20 pm »
Hey guys,

  I was experimenting with implementing a runtime in SFML for GrapeFrukt exported animations (https://github.com/grapefrukt/grapefrukt-export).  But I have run into a bit of an issue I feel ill equipped to tackle.  In my first run, I noticed that all the animations were extremely pixelated when transformed (scaled, rotated, etc..), so I turned on texture smoothing.

This fixed a lot of my aliasing issues, but introduced a bunch of alpha artifacts around the text that has a drop shadow.  
It looks like a pre-multiplied alpha issue, but I'm not sure how to fix it in SFML (I'm using the .NET bindings).  I did a search for "pre-multiplied" and came up with very little.  I'm fairly certain this could be address with the new BlendMode stuff in the SFML repo, but documentation on how to use it is a bit scarce at the moment.

Thanks,
Rob

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Alpha artifacts
« Reply #1 on: November 10, 2014, 05:00:34 pm »
So what is your problem exactly? Finding the formula for pre-multiplied alpha, or finding how to apply it with SFML?
Laurent Gomila - SFML developer

rcurtis

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Alpha artifacts
« Reply #2 on: November 10, 2014, 05:18:24 pm »
Laurent,

Thanks for the reply.  I am using

Code: [Select]
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

in my draw call for debugging and it gives even greater issues





This was rendered with mipmaps set to GL_LINEAR (which I believe SFML does with texture smoothing).  I 'm thinking this is not a pre-multiplied alpha issue, but I'm really not sure what to check next.


Here is the text graphic that is being rendered on top of the other images if your interested:



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Alpha artifacts
« Reply #3 on: November 10, 2014, 08:19:51 pm »
I'm not sure if there's a perfect solution to this. Either you don't smooth and get aliasing issues, or you smooth and you get alpha-blending problems at edges.
« Last Edit: November 10, 2014, 08:21:43 pm by Laurent »
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Alpha artifacts
« Reply #4 on: November 10, 2014, 09:55:07 pm »
You could try to enable the window's anti-aliasing to affect the whole rendered screen, not just a transformed texture.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

rcurtis

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Alpha artifacts
« Reply #5 on: November 11, 2014, 03:13:45 pm »
You could try to enable the window's anti-aliasing to affect the whole rendered screen, not just a transformed texture.

Are you talking about openGL multisampling?  If so, I am currently using multisampling with a value of 4 when the context is created.

 

anything