Page 1 of 2

No blend mode.

Posted: Sun Jun 07, 2009 11:05 pm
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 8016 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.

Re: No blend mode.

Posted: Mon Jun 08, 2009 2:27 pm
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.

Re: No blend mode.

Posted: Mon Jun 08, 2009 3:46 pm
by rude
You want the union of the two shapes to act as one transparent object?

EDIT: Rephrased.

Re: No blend mode.

Posted: Mon Jun 08, 2009 4:23 pm
by ljdp
Yes, what rude said.

Re: No blend mode.

Posted: Mon Jun 08, 2009 4:35 pm
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:

Re: No blend mode.

Posted: Mon Jun 08, 2009 4:42 pm
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
:?

Re: No blend mode.

Posted: Mon Jun 08, 2009 4:45 pm
by Robin
If you're interested: my hack works. I've added a small example.

Re: No blend mode.

Posted: Mon Jun 08, 2009 4:48 pm
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

Re: No blend mode.

Posted: Mon Jun 08, 2009 5:08 pm
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.

Re: No blend mode.

Posted: Mon Jun 08, 2009 7:21 pm
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