Jump to content


OpenGL blending issue


2 replies to this topic

#1 Stainless

    Member

  • Members
  • PipPipPipPip
  • 610 posts
  • LocationSouthampton

Posted 10 April 2013 - 11:54 AM

I did a quick demo for a company, I can't show any screen shots, or talk about the app, as it is wrapped up in the sort of NDA that is scary.

In general though it has fixed elements and moving elements. The fixed elements are drawn onto the opengl screen with alpha blending enabled. I don't clear the screen, so the moving elements fade out gradually.

The issue is that they never fade out completely. You end up with a very feint gray shadow on the screen.

I don't understand why

Say you start out with a value of 64 and alpha blend 0,0,0,0.9 over the top

final pixel = 64*0.1 + 0*0.9 = 6.4
final pixel = 6*0.1 + 0*0.9 = 0.6

So it should go to zero

Anybody know why it doesn't

#2 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 517 posts
  • LocationNowhere whenever

Posted 10 April 2013 - 12:08 PM

Assuming ONE_MINUS_SRC_ALPHA / SRC_ALPHA and the default blend formula you should get what you described.

However, if you have the formula reversed (1-a and a swapped), you get:

out = dst*0.9+0*0.1

which leads to:

64,58,52,47,42,38,34,31,28,25,23,21,19,17,15,14,13,12,11,10,9,8,7,6,5,5,5,5,5,5,5,5,5,5,5,5,5....

(5*0.9 = 4.5 ~ 5)

Any alpha value more or equal than 0.5 won't fade to black because the result will eventually get rounded to more than 0.
http://iki.fi/sol - my schtuphh

#3 Stainless

    Member

  • Members
  • PipPipPipPip
  • 610 posts
  • LocationSouthampton

Posted 10 April 2013 - 01:31 PM

It rounds up? :angry:

man thats' a pain in the proverbial





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users