No blend mode.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

No blend mode.

Post by ljdp »

Is there a way to have no blending.
For example you have a group of shapes overlapping each other and you set a transparent colour
and they all become transparent (so they look like one single object)
overlappingshapes.JPG
overlappingshapes.JPG (2.55 KiB) Viewed 7893 times
If you look at that there are 4 circles and 5 rectangles, but they overlap so you can see the seperate objects.
I want them to look like one object.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: No blend mode.

Post by Robin »

I think you could try drawing the background first, next the shapes with 100% alpha, and then the background again with a lower alpha. I have no idea whether this actually works.
Help us help you: attach a .love.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: No blend mode.

Post by rude »

You want the union of the two shapes to act as one transparent object?

EDIT: Rephrased.
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

Re: No blend mode.

Post by ljdp »

Yes, what rude said.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: No blend mode.

Post by rude »

I wonder if this is possible with glBlendFunc at all. Hmm, I don't think it can be combined with normal blending (transparency).

Might need to implement render targets for this. :brows:
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

Re: No blend mode.

Post by ljdp »

Well I don't really know how blending works.
But I assume it takes each pixel of an object and does some math between the values.
Can't you just say

Code: Select all

if object1Color == object2Color then
     finalColor = object1Color
end
:?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: No blend mode.

Post by Robin »

If you're interested: my hack works. I've added a small example.
Attachments
noblend.love
(383 Bytes) Downloaded 317 times
Help us help you: attach a .love.
User avatar
ljdp
Party member
Posts: 209
Joined: Sat Jan 03, 2009 1:04 pm
Contact:

Re: No blend mode.

Post by ljdp »

Nice!

EDIT: lol, looking at your code it never occured to me you only needed to draw 2 rectangles for a rounded box :rofl: i've been drawing 5
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: No blend mode.

Post by Robin »

ljdp wrote:(...) you only needed to draw 2 rectangles for a rounded box :rofl: i've been drawing 5
:D yeah

The bad news is: my hack is a bit limited. It's hard to have objects of different transparencies (you could of course add layer on top of layer, but then you can't choose the drawing order yourself), and a completely opaque shape is always on the foreground. Unless you make it part of the background, in which case you have to draw everything at least twice.

I think the best solution would be to allow drawing to off-screen buffers, and blitting them later, with optional transparency.
Help us help you: attach a .love.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: No blend mode.

Post by osgeld »

Robin wrote: I think the best solution would be to allow drawing to off-screen buffers, and blitting them later, with optional transparency.
This is one of the things i miss most with love, its just so darn useful for so many things
Post Reply

Who is online

Users browsing this forum: No registered users and 180 guests