• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

white sprite on black - remove black?

A

anomalous

Guest
I have a white sprite with gradient to black (like a particle glow in white on black background).
Is there a way to change the black to transparency, such that it becomes a white sprite gradient to transparent?
I would like ultimately to draw to a surface than save the surface as a sprite.

I tried a few types...clear to black and use bm_normal and bm_add, no luck so far.

If I use this as a particle with bm_add set, it actually doesn't draw the black..which is what gave me the idea. (but I still need it as a white gradient to transparency).
 
Last edited by a moderator:
E

elementbound

Guest
If you'd like to do this in runtime ( aka. via GM's tools ), you can do that with a shader. Just create a new one, and modify the fragment shader's main:
Code:
gl_FragColor = vec4(1.0, 1.0, 1.0, texture2D(gm_BaseTexture, v_vTexcoord).r);
Bind this shader, and draw whatever you want. The shader will actually use the red channel, but since we are using a grayscale shader, all the channels look the same. The shader will output a purely white image, with transparency based on brightness ( red channel )
 
A

anomalous

Guest
Great thank you!
I also figured out how to do it in photoshop, but I like the game maker version..can do a lot at once.
 
I

iMilchshake

Guest
You could also go into the Sprite-editor. Then Go to "Image" -> "Erase a Colour"
 
A

anomalous

Guest
Unfortunately erase a color won't give white to transparent, it will just cut out the black pixels entirely (and more than black with tolerance, its a nice feature for other stuff)
 
I

iMilchshake

Guest
Unfortunately erase a color won't give white to transparent, it will just cut out the black pixels entirely (and more than black with tolerance, its a nice feature for other stuff)
Ohh.. Yeah i forgot..
Good you found a solution^^.
 
Top