Brightness effect that preserves alpha?

Discussion and feedback on Construct 2

Post » Sun Dec 30, 2012 9:04 am

I wanted to use the brightness effect to create a black outline of my sprite (that I use for a specific game mechanic).
More graphically speaking I have this
Original Pic
and I want to get this (through a smooth darkening animation (so using animations is out the question).
Darkened silhouette

However, after applying the brightness effect I actually got this:
Non-alpha brightness

The problem is that the effect does not preserve the alpha of the original sprite.
Is there currently a way to get a brightness effect that does preserve alpha?

Thanks in advance

PS: I apologize if this is not the correct place to post but I wasn't sure if this was a bug (as most of the other effect do seem to preserve alpha) or a "how do I do?" (because there are well-known ways to do this) or a feature request (because that it is something that is known to be missing)Alcemon2012-12-30 09:25:16
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Sun Dec 30, 2012 1:21 pm

In the meantime, the "exposure" effect seems to also do something similar and it does preserve alpha. Hopefully this is not that much computationally intensive than the regular "brightness effect".
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Sun Dec 30, 2012 2:08 pm

Try using the 'Set color' shader instead.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sun Dec 30, 2012 2:32 pm

Thanks for the reply. Set color is slightly different though, as there is no value in which the object is presented as it would be normally (Brightness = 100 means no change applied).

In any case, is there some sort of rule or reason for preserving alpha on some color effects and not in others?

No biggie though, worst case scenario I would create another effect "alpha preserving brightness" on my own.

Thanks again and happy new year!
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Sat Jan 05, 2013 9:42 am

A final tip for this.

If there is an effect that does not preserve alpha and you want it to preserve alpha, go into your effect directory and find the name effect you want to edit.
1) Open <effect_name>.fx
2) See if you can find any of the following lines of javascript code:
   front.rgb /= front.a;
   front.rgb *= front.a;
3) Comment them by adding "//" to the beginning of that line
4) Save with a different name
5) Open <effect_name>.xml and make sure to change the id that its found between "<id>" and "/<id>" to another value (each effect is required to have a different id).
6) Save with the same name as your .fx file
7) Close and Open C2 and use your new alpha preserving effect

Of course, this does not work with every effect but I could at the least apply it to the "brightness" and the "vignette" effects that I wanted to use in my project.
B
19
S
4
G
4
Posts: 70
Reputation: 3,896


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 18 guests