Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Pre-multiplied Alpha for drawing particles in one pass  (Read 6710 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #30 - Posted 2012-08-22 10:03:18 »

I can't stress highly enough how WRONG using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) is. NEVER USE IT. Just about every example ever on the internet and in books uses this blend function, and it is wrong wrong wrong.
As you point at additive blending for everything, how exactly do you subtract color from the framebuffer, like you do with regular blending...?

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) has its uses...

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #31 - Posted 2012-08-22 10:03:45 »

Oops, missed your bit about doing the multiply at upload time, yeah that's a nice way of handling it. But it still doesn't produce any tangible benefits that I can see.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #32 - Posted 2012-08-22 10:05:37 »

@Riven - to be sure it's got a use but just not the use that everyone thinks it has.
@OrangyTang - basically why muck around with bleeding pixels and other hax when you can just use the correct blending mode and fix the edge artifacts automatically and get your glow and transparent particles done using the same shader/ffpipeline functions?

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #33 - Posted 2012-08-22 10:05:41 »

Oops, missed your bit about doing the multiply at upload time, yeah that's a nice way of handling it. But it still doesn't produce any tangible benefits that I can see.
The problem with regular blending is terrible color banding issues (see my YUNPM library, where I abuse it to create a blur)


Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #34 - Posted 2012-08-22 10:16:18 »

@Riven - to be sure it's got a use but just not the use that everyone thinks it has.
@OrangyTang - basically why muck around with bleeding pixels and other hax when you can just use the correct blending mode and fix the edge artifacts automatically and get your glow and transparent particles done using the same shader/ffpipeline functions?

Cas Smiley

Meh. Now we're back to hand-wavey arguments about what's more 'correct'. Yet by colour bleeding I've maintained the orthogonality of the colour and alpha data, which is important as soon as you're doing anything other than straight blitting. Which is why I see this as firmly in swings-and-roundabouts territory, rather than "you must use pre-multiplied alpha".

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #35 - Posted 2012-08-22 10:18:26 »

Don't get me wrong, this is for straight blitting. If you're doing something fancypants that is not sprite/particle related then assuredly you might have other uses for the other blending mode. But my guess is you are doing sprites and glowy particles, and if that's the case, you want to do it right.

Cas Smiley

Offline nsigma
« Reply #36 - Posted 2012-08-22 18:53:23 »

Image composition and filtering were what did it for me.

Composition was in particular key for me.  If you're ever doing layered composition, rendering to a transparent texture first, then pre-multiplied is essential to get the right result.

Some other useful blend modes are not possible (shy of shaders) without pre-multiplied data as well - Multiply in particular.

Just realised that one of the posts I read a while back that I found useful was the TomF one in the OP's post - just his link was broken by the forum!

As you point at additive blending for everything, how exactly do you subtract color from the framebuffer, like you do with regular blending...?

What exactly do you mean by subtract?  Actually, I think that question is the nub of why people don't get this - standard blending should be an additive / accumulative process, and there's a reason all blend modes (PorterDuff, etc.) are expressed in terms of pre-multiplied alpha.  The blend function you give isn't an Add blend though - if you draw fully opaque black on white you'll end up with black (GL_ONE_MINUS_SRC_ALPHA on dst).

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #37 - Posted 2012-08-22 19:31:40 »

As you point at additive blending for everything, how exactly do you subtract color from the framebuffer, like you do with regular blending...?
What exactly do you mean by subtract?  Actually, I think that question is the nub of why people don't get this
If that isn't a flamebait, I don't know what is...

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #38 - Posted 2012-08-22 19:42:28 »

Colour "subtraction" is still being performed on the framebuffer - the destination factor is still the same GL_ONE_MINUS_SRC_ALPHA as you might have used before. The alpha component of the texture is still the same as it was; it is now describing effectively how much of the framebuffer to show through the sprite. So at 255, that's none; the existing pixels will have no bearing on the final colour.

Cas Smiley

Offline nsigma
« Reply #39 - Posted 2012-08-22 20:18:32 »

@riven - definitely not my intention. I'm sorry that you feel everything I'm saying atm is a criticism. It's honestly not meant that way.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #40 - Posted 2012-08-22 20:20:30 »

Time of the month Wink

Cas Smiley

Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (40 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!