SFML community forums
General => Feature requests => Topic started by: tireswing on February 27, 2009, 11:56:29 pm
-
Blend::Add ignores the source image's alpha channel.
In my game, I am using some special effects where I want an additive blend mode, but I need it to use the source image's alpha channel as well.
The GL blend function I need is:
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
It was really simple to change SFML to do this, but I'd like to stay standard to maintain a good upgrade path. It would be helpful to add a new blend mode to handle this.
Thanks
-
Actually, I think there's no point ignoring the source alpha, so I could even use your solution as a replacement for Blend::Add instead of creating a new one.
-
It's done.
Thanks for your feedback :)
-
Sounds great! Thanks!!
-
rather than make a new thread i thought i would request some additional blending modes (also since you use glblendfunc for blending is there any chance in the future of being able to define the blending ourselves?)
anyway here are the blending modes i would like to request using the following two textures as an example:
(http://img.photobucket.com/albums/v473/UArchitect/th_tex.jpg) (http://smg.photobucket.com/albums/v473/UArchitect/?action=view¤t=tex.jpg)
Modulate
Modulate = src*dest+src*dest or (dest*src)*2 = glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
(http://img.photobucket.com/albums/v473/UArchitect/modulate.jpg)
useful for decal textures which can lighten and darken
Screen
Screen = src+(1-src)*dest = glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);
(http://img.photobucket.com/albums/v473/UArchitect/screen.jpg)
same as "screen" blend mode in photoshop, its like add but doesnt overbrighten and doesnt look as harsh
(http://img.photobucket.com/albums/v473/UArchitect/blendcomp.jpg)
thanks in advance if you consider any of these
-
Modulate --> it's like Blend::Multiply, except mine is not multiplied by 2. Does the *2 actually mean something ?
Screen --> is it really useful? If so, can you give me some examples?
My concern here is to keep a limited number of blend modes, so that the user is not confused with the tons of combinations usually available.
-
hello, are the pictures in my above post showing properly?
anyway modulate is a bit like multiply but it works similarly to the overlay mode in photoshop
lower than mid gray = darken
higher than mid gray = lighten
it just means i can have a "decal texture" which can darken and brighten rather than just darken (like the bullet holes above)
Modulate --> it's like Blend::Multiply, except mine is not multiplied by 2. Does the *2 actually mean something ?
rather than just src*dest (multiply)
its src*dest + src*dest, or to be put simpler (src*dest)*2
which means mid-gray will cause the underlying colors to be unaffected, higher than mid gray will lighten and lower than mid gray will darken
screen is like additive but its much softer, it preserves detail in lighter areas it wont bleach out and cause things to turn into white blobs which in certain situations it looks alot nicer (partivcularly when you have many overlapping translucent objects)
heres an example:
many sprites overlayed using screen blending:
(http://img.photobucket.com/albums/v473/UArchitect/screenmode.jpg)
the same image but using additive blending:
(http://img.photobucket.com/albums/v473/UArchitect/addmode.jpg)
anyway, im not demanding or anything i imagine i could add custom blending modes myself but i wanted to throw the idea out there for consideration :>
-
Ok I see. It's interesting :)
I'll think about it, thanks for your feedback.
-
np, thanks for responding