[Help] Surface Export and transparency

Tangramd

Member
Hello everyone, first post here !

I usually managed to find solutions on this forum but this time I'm really stuck and I need your help !
I'm having a hard time dealing with alpha and surfaces, and I don't get it. For some reason my sprites behave oddly.

sample.jpg

LEFT : 2 times the same sprite overlaping, drawn the usual way (draw_sprite_ext in an object), that's what I'm trying to get using a surface.

GML:
draw_sprite_ext(_sprite,1,_i,_j,_xscale,_yscale,_angle,c_white,1)
RIGHT : the same sprites drawn exactly the same way but on a surface, which is then drawn on the application surface. My surface is cleared with black and 0 alpha every frame
GML:
// draw surface parts

draw_surface(parts,560,0)


//reset surface

surface_set_target(parts)
draw_clear_alpha(c_black,0);
surface_reset_target();
As you can see the transparency is clearly messed up. (halo is smaller, but also transparecy affecting the sprite underneath - you can see the the grid under it)

I tried many things with blend modes but nothing worked properly.

Any Idea?

(here's the original sprite)

sprite.png

Thank you very much,

J
 
Last edited:

FoxyOfJungle

Kazan Games
Try gpu_set_blendenable()

GML:
gpu_set_blendenable(false);

draw_surface(parts,560,0);

gpu_set_blendenable(true);

And/or gpu_set_colorwriteenable();

GML:
gpu_set_colorwriteenable(true,true,true,false);
gpu_set_blendenable(false);

draw_surface(parts,560,0);

gpu_set_blendenable(true);
gpu_set_colorwriteenable(true,true,true,true);
 

Tangramd

Member
Sorry, in fact, in doesn't exactly work, it shows the surface correctly in game but the surface itself is still transparent. I need to export it and the .png file looks like before : as you can see.

Is there any way to correct the surface itself and not the way it's displayed in game?
random token.png
 

FoxyOfJungle

Kazan Games
I understand what you want to do and I went through this when making my program, what happens is that it will depend on the way you are drawing its surface, that is, where you are drawing it, you will use the same functions that I quoted, but it will have to be used correctly to work.

Try to save the surface from the draw event, before destroying the surface.





One of the surfaces saved in the gif is not with the correct alpha, but it is intentional, as I was testing it.
 
Last edited:
Top