Archived

This topic is now archived and is closed to further replies.

Alexandre Brien

problem with some textures in my tile engine

Recommended Posts

Hey, just ran in a problem in a tile-based engine im working on (like the older final fantasys) the way i draw my tiles is by applying a texture (.bmp) to a quad. So the world map is hundreds of quads with textures on em. My problem is that my character texture (the character that walks on the map) is square too, and it's ugly because I cant get the unused part of the texture to be invisible, so basically I have a square running around the map =( any ideas?? does the .bmp format allows transparency or something?? heres what I mean: http://pages.infinit.net/mnok/tileproblem.jpg [edited by - Alexandre Brien on June 9, 2002 6:12:38 AM]

Share this post


Link to post
Share on other sites
Prosper/LOADED    100
The easiest solution would be to use 32 bit textures. Set the alpha channel to white for opaque pixels and black for transparent ones. Then, before you draw your sprites (but not your tiles), you just use glAlphaFunc( GL_GREATER, 0.5f) (remember to also call glEnable( GL_ALPHA_TEST))to draw only the pixels with a great enough alpha value.

You can''t use BMP to achieve this. TGA and PNG are good solutions. There''s a NeHe''s tutorial which deals with TGA loading.

Share this post


Link to post
Share on other sites
ok I switched to TGA and got it working again, but for my tiles that are 32-bit and that needs transparency, they dont show at all =)

Is there anything specific I need to do in photoshop??
What I do is create a new image, I set it to RGB(theres no RGBA options) with transparent content. Then I paste my tile there and lasso out everything that needs to be out. Then I save to .tga with 32 bit, but for some reason it fills up the transparent area with white...

heres what I do in the app (note that it doesnt work with any setting of glAlphaFunc (0 to 1)):

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);

//characters need to be transparents.
world.DrawCharacter();

glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);

//map tiles dont need to be transparent.
world.DrawMap();

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
You''ve to add a new channel for your image (photoshop->channels->add, on the right side windows somewhere) - this is the alpha channel. Set to black where you want your image to be transparent, and white where it''s opaque (and anything inbetween for translucency)

llyod@work

Share this post


Link to post
Share on other sites