Handmade Hero»Forums»Game
19 posts
Premultiplied alpha in the software renderer
Edited by Terans on Reason: Initial post
Hi, I'm at around day 320, and I don't understand why we have to set glBlendFunc to non premultiplied alpha when rendering a `blend_render_target`, does it mean that the software renderer only draws rectangles and bitmap that are non-premultiplied alpha? If it's the case, why do we do that? Isn't faster to premultiply the color before starting the rectangle drawing and then only use the simplified blending equation with premultiplied alpha?
Simon Anciaux
1337 posts
Premultiplied alpha in the software renderer
Could you be more precise with which episode you're talking about and give a timestamp ?
19 posts
Premultiplied alpha in the software renderer
My question is does the software renderer use premultiplied alpha? Because when we blit the blend_render_target in OpenGLRenderCommands, we use glBlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA) which is the equation for non premultiplied alpha, so does that mean that the software renderer doesn't do premultiplied alpha?
Simon Anciaux
1337 posts
Premultiplied alpha in the software renderer
It's been years since I watched those episodes and I'm rusty about pre-multiplied alpha. I don't know if the renderer uses premultiplied alpha. But I think it doesn't matter at that point (and I may be wrong). Pre-multiplied alpha matters when you're compositing different sprites together, but once the image has been composed and you want to put it on the screen, you can use "SRC_ALPHA, ONE_MINUS_SRC_ALPHA" to blend it with the clear color.
19 posts
Premultiplied alpha in the software renderer
Ok thanks!