« Jesus wants you to optimize your code... | Main | Programming for morons? »

09/25/2012

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Uncompetative

Bret Victor's proposed coding environment would have saved you time here.

Sean Barrett

Your solution is the technique every idiot game developer hacks together, but it is in fact the lame hacky bullshit solution, because (a) it can still produce artifacts if there are prominent color changes in the pixels that are partially transparent, (b) it is obviously bullshit hackery (look at me fucking with pixel colors). If there were no other solution than bullshit hackery, then fine, but in fact there is a simple approach that's been known since 1984.

The correct solution is to use premultiplied alpha, for which bilinear filtering produces the correct results. I leave it to you to google any of the millions of articles about premultiplied (it's what the movie industry uses), since my 2004 Game Developer Magazine article on the subject ("Blend Does Not Distribute Over Lerp") isn't available online.

[I have adjusted the tone of this comment to try to match the tone of your blog; I hope that helps.]

Stephen Nichols

"Imitation is the sincerest form of flattery...". :)

You're not the first person to point out the magic bullet of "premultiplied alpha." Since you are a master of using this technique, I'm sure you can envision reasons why it might not be applicable to my situation.

For fun, I'll explain the most important reason for you here:

The middleware solution I'm using for this project abstracts away GLES support so that we can target a wide range of devices. It even supports software rendering. Of course, this level of abstraction comes with a price. There's no support for premultiplied alpha textures in the generic API. So, while I could solve this problem with premultiplied alpha, it would take a nice rewrite of the rendering layer to accommodate it. So, I took the fast solution. And that works just fine for me.

Stephen Nichols

Uncompetative:

For starters, you can't even spell uncompetitive right. That brings your comment down to near zero value straight away. Then, there's the sycophantic content.

"Ooooh, Brett's utopia vision where programs almost debug themselves would have saved you time here." Really? Yeah, I guess I should have waited for some academic to implement his bullshit scheme before I spend an hour solving the problem on my own.

Nah, I'll just solve the problem and let you wait for the nanny IDE so you can get to work.

Sean Barrett

There's nothing you need to do to support premultiplied alpha other than premultiply the alpha and use a slightly different blend mode. Software renderers are _more_ efficient at premultiplied blending, so if you actually can't do this, the middleware you're using is terrible.

"I can't do this the right way because this middleware sucks" is actually a more useful blog post than "hey guys, I rediscovered the same shitty solution everyone else uses because they're idiots".

Sean Barrett

Let me put a different way.

The Internet is full of blog posts by the incompetent leading the incompetent. People love to tell each other the "clever" ways they've discovered to do things, whoo, aren't they smart.

If you want your blog to ACTUALLY be a blog that bucks that trend, this post does not do that. Either premultiplied alpha isn't better, or premultiplied is better but you can't use it. The post isn't written from either perspective, because it doesn't even acknowledge the existence of premultiplied alpha.

So yes, I assumed I was actually the first person to point this out, because if I wasn't, if you already knew about it and you were actually trying to accomplish the goal you described in the first post, you'd have mentioned it. I preferred to imagine you had no idea about the solution and would like to learn it, rather than to assume you're a jackass who knew about it and intentionally led anyone who read your post down a wrong and stupid path of bullshit hackery.

You're welcome.

Stephen Nichols

I like that you keep trying to insult me. It feels good. Keep it up!

Premultiplied alpha isn't better. You say that it is, but you don't substantiate it. It's a solution, but not necessarily the best one. But, it doesn't work in my case without some extra work. I'll wager it won't work for other people as well.

The solution I outline is a hack? Why? You don't substantiate that very well either. You say:

(a) it can still produce artifacts if there are prominent color changes in the pixels that are partially transparent

(b) it is obviously bullshit hackery (look at me fucking with pixel colors)

Looking at the source images in my article should make clear that (a) is a non-issue for me. They're grayscale textures.

And, being that (a) is a non-issue, you pull (b) out of your ass. Yeah, I'm "fucking with the pixel colors." And that's a hack because? Oh, right, you don't say. Yes, we should all avoid changing the pixels in our images because that's a hack. Weak.

So, to sum up your complaint with this article... because I don't mention premultiplied alpha as a possible solution, the solution is a hack and wrong? Clever points, but I just can't agree with you.

Thank you, come again...

The comments to this entry are closed.