3D Using SWF sprites in 3D

Posho

Member
Hello everyone, it's good to be back. This is my first post in the new forums, which by the way, they look fantastic. Hope we can make this community great. ;)

Alright, so I just stumbled with a little issue here. Just to get things clear right off the bat, I know SWF files don't merge in 3D. The thing is that my project will make use of lots of sprite work, which can really benefit from being in SWF rather than PNG files because of the many resolutions that the game auto-adjusts into because it's a mobile game, so I really need the final project size to be as small as possible and because they're all made in Flash in the first place.

Funny thing though, I was able to project SWF sprites as 3D walls by simply drawing the SWF sprite into a surface, then saving it as a new sprite, then using such sprite as the texture for the 3D wall. It works! However, it looks like crap. Take a look.

This is how the sprite looks with the draw_set_swf_aa_level set to 1.
It looks kinda decent in the sense that it is lossless, but it has an ugly blue outline around it.

This is how the sprite looks with the draw_set_swf_aa_level set to 0.
The blue outline is now gone but the quality of the image is now lower, and the sprite now looks very pixelated.

I'd like to make my 3D projections look like the first image, but without the blue outline. I don't even know where the blue came out or why it is blue in the first place. The problem could easily be fixed if the contour was black instead of blue. I figured that the outline could be removed with draw_clear_alpha(c_blue, 0);, which is needed anyways or the image simply won't display.

Here's the code of the script I use to make this work if you want to give it a look:
Code:
///sprite_tween(SWF sprite, subimage)

draw_enable_swf_aa(true);
draw_set_swf_aa_level(1);

surf = surface_create(sprite_get_width(argument0),sprite_get_height(argument0))
surface_set_target(surf)
    draw_clear_alpha(c_blue, 0);
    draw_sprite(argument0,argument1,0,0)
surface_reset_target();
spr = sprite_create_from_surface(surf,0,0,sprite_get_width(argument0),sprite_get_height(argument0),true,true,sprite_get_width(argument0)/2,sprite_get_height(argument0))
surface_free(surf)
sprite_index = spr
The sprite_index is then later used as the variable represents the sprite texture for 3D.

Anyone knows what's up with this? How can I fix this? I know SWF with 3D in GameMaker: Studio is kind of an unexplored area but is there anything I can do with this? Like I said, I think everything could be easily fixed if I could be able to transform the blue outline into black somehow.

Also, while we're at the SWF topic, does anyone know if there's a way to manipulate the quality of an SWF while the game is executed? Like, so I could put a quality slider in the game?

Anyways, thanks if you actually read all this. I'll wait for a response.
Cheers. ;)
 

orange451

Member
It's a problem with alpha testing when rendering 3d graphics.

There are two solutions.
1) Depth sorting
2) Don't have non opaque pixels

To do #1, you just have to set the objects depth based on the distance to the camera. Here's a good article on it.

To do #2 you need to clip your alpha pixels. To do this, you need to create a pass-through Shader, and when outputting the geometry's fragment to the buffer, discard any texel with an alpha of less than 0.1, and set the alpha to 1.0 for any other texel.
 
Top