• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualSuperVGA

Posted 03 February 2013 - 02:17 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

If I try to compute the result myself. (given that the transparent regions of src are black with an alpha value of 0.00)

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs. (Should become nice and generic. )

Without lerping between any colour and white, I'd like to be able to have the overlayed GUI element fade out, while still keeping the effect.

Say, I have a red light filter taking up the entire screen, resembling the player having been shot, fading out slowly, and things gradually come back to their original colours.

### #7SuperVGA

Posted 03 February 2013 - 02:16 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs. (Should become nice and generic. )

Without lerping between any colour and white, I'd like to be able to have the overlayed GUI element fade out, while still keeping the effect.

Say, I have a red light filter taking up the entire screen, resembling the player having been shot, fading out slowly, and things gradually come back to their original colours.

### #6SuperVGA

Posted 03 February 2013 - 02:12 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs. (Should become nice and generic. )

Without lerping between any colour and white, I'd like to be able to have the overlayed GUI element fade out, while still keeping the effect.

Say, I have a red light filter taking up the entire screen, resembling the player having been shot, fading out slowly, and things gradually come back to their original colours.

### #5SuperVGA

Posted 03 February 2013 - 02:12 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs. (Should become nice and generic. )

Without lerping between any colour and white, I'd like to be able to have the overlayed GUI element fade out, while still keeping the effect.

Say, I have a red light filter taking up the entire screen, resembling the player having been shot, fading out slowly, and things gradually come back to their original colours.

### #4SuperVGA

Posted 03 February 2013 - 02:10 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs.

(Should become nice and generic. )

### #3SuperVGA

Posted 03 February 2013 - 02:09 PM

Hi Guys!

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect. I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it, and as that isn't really stored anywhere, there must be something else I'm doing wrong.

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)

// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.


I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.

Src. (What I draw to the colour buffer)

Dst. (What's already in the colour buffer)

Desired. (I'd really like to see this result)

Achieved. (I'm getting this result. )

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs.

(Should become nice and generic. )

PARTNERS