Proposal: love.graphics.alpha()

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Proposal: love.graphics.alpha()

Post by Jasoco »

If possible, I propose we add a love.graphics.alpha() function to the transformation stack. Why? Well basically, here's how it would work.

It would apply an overall transparency to everything being drawn during the transformation stack instead of using the alpha argument on setColor. The problem with setColor is that it applies it to every draw operation separately so overlapping objects become obviously overlapped and may break the illusion to the player. love.graphics.alpha would apply the transparency to everything being drawn overall.

In the below example:
Top: Drawing everything with normal 100% opacity (255 alpha)
Middle: Setting 60% opacity to all objects separately (153 alpha) - Notice the photo showing through the text and polygon
Bottom: Setting 60% opacity to the transform stack while everything is drawn at 100% opacity using love.graphics.alpha() - Notice there is no peek through from objects drawn behind other objects
alpha.jpg
alpha.jpg (142.23 KiB) Viewed 3409 times
Basically it would be the same outcome as drawing everything to a canvas then drawing the canvas with a partial transparency. The problem is not everyone can use canvas.

I'm wondering if this would even be possible. I mean we can translate and rotate and scale, but not change alpha? Is this a limitation? Would it just not be possible without canvases anyway?
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Proposal: love.graphics.alpha()

Post by Boolsheet »

The pentagon, the image, and the glyphs of the text are all separate drawing operations. They even get split up into smaller pieces so they're all triangles. Each triangle gets rasterized and then blended with the framebuffer (what you see on screen, more or less). Unless I'm missing some test or blend mode combination in OpenGL, your proposal requires that it remembers where something already has been drawn. This is kind of possible already with stencils, but it's necessary to redraw them for every shape which is mighty slow. I guess the depth buffer could be of help here, but if it is ever exposed in LÖVE, I think it's going to be in a more generalized way.
Shallow indentations.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Proposal: love.graphics.alpha()

Post by Jasoco »

Seems Canvases would be the best way to do it right now. Shame they don't work everywhere.
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Proposal: love.graphics.alpha()

Post by slime »

Jasoco wrote:Seems Canvases would be the best way to do it right now. Shame they don't work everywhere.
The people who own computers which can't use framebuffers/canvases usually don't expect to be able to play recent games with said computers. :)
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Proposal: love.graphics.alpha()

Post by Jasoco »

slime wrote:
Jasoco wrote:Seems Canvases would be the best way to do it right now. Shame they don't work everywhere.
The people who own computers which can't use framebuffers/canvases usually don't expect to be able to play recent games with said computers. :)
A lot of brand new machines can't support Canvas and a lot of really old ones can. It's not a new vs. old thing. It's a driver thing.
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Proposal: love.graphics.alpha()

Post by slime »

Jasoco wrote:
slime wrote:
Jasoco wrote:Seems Canvases would be the best way to do it right now. Shame they don't work everywhere.
The people who own computers which can't use framebuffers/canvases usually don't expect to be able to play recent games with said computers. :)
A lot of brand new machines can't support Canvas and a lot of really old ones can. It's not a new vs. old thing. It's a driver thing.
It's a matter of hardware and drivers. A few intel integrated GMA cards, while being "recent" (aka 5+ years old), just aren't designed for modern OpenGL use, and can't create canvases. You can't take a TNT2 and slap some new drivers on it and expect it to gain (hardware-accelerated) canvas support. :)

As far as I know, all GPUs from ATI/AMD/nvidia made in the past ~9 years support* canvases (provided they have non-ancient drivers), and all intel integrated chips aside from a couple GMA models do as well.

*There is an oversight in 0.8.0 which prevents canvases from working with certain older systems, but this is fixed for 0.9.0.
Kyle
Party member
Posts: 146
Joined: Sat Mar 16, 2013 9:46 pm

Re: Proposal: love.graphics.alpha()

Post by Kyle »

Those with the crappy GMA chips don't usually expect to play many new games anyway, to be honest.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Proposal: love.graphics.alpha()

Post by Jasoco »

Kyle wrote:Those with the crappy GMA chips don't usually expect to play many new games anyway, to be honest.
My computer, even my last one, both have "crappy GMA" video chips and they do Canvases and PixelEffects fine. And support images upwards of 2048x2048 and larger, including canvases.

Unless a HD3000 and HD4000 isn't crappy.
Clouds
Prole
Posts: 23
Joined: Tue Nov 27, 2012 4:06 am

Re: Proposal: love.graphics.alpha()

Post by Clouds »

Kyle wrote:Those with the crappy GMA chips don't usually expect to play many new games anyway, to be honest.
I can't imagine anyone who doesn't have at least general knowledge of OpenGL implementation (in other words, "most people") thinking any 2D game is a "new game" in the sense of being even slightly demanding of hardware.
Jasoco wrote:Unless a HD3000 and HD4000 isn't crappy.
Nope, those aren't the "GMA" series accelerators that are in question.
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Proposal: love.graphics.alpha()

Post by slime »

Jasoco wrote:
Kyle wrote:Those with the crappy GMA chips don't usually expect to play many new games anyway, to be honest.
My computer, even my last one, both have "crappy GMA" video chips and they do Canvases and PixelEffects fine. And support images upwards of 2048x2048 and larger, including canvases.

Unless a HD3000 and HD4000 isn't crappy.
Intel's latest HD 2000/3000/4000 GPUs are quite good, considering what they are. They are also not GMA's.
Clouds wrote:
Kyle wrote:Those with the crappy GMA chips don't usually expect to play many new games anyway, to be honest.
I can't imagine anyone who doesn't have at least general knowledge of OpenGL implementation (in other words, "most people") thinking any 2D game is a "new game" in the sense of being even slightly demanding of hardware.
Most people who have computers with the sort of chip that can't do post-millenium techniques will likely not play any downloadable game at all that has any sort of minimum requirements listed.

For example, all games created with Microsoft XNA will not work with an Intel GMA 950. Terraria was made with XNA. You do not have to support every system under the sun to meet people's expectations.

I should also mention that canvases, like images, use an opengl texture under the hood. But unlike images, canvases do not auto-pad the texture to power-of-two dimensions on systems that don't support npot textures, so your system may be experiencing PO2 syndrome if you get an error making a canvas.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], varpeti and 4 guests