Archived

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

solid transparency

This topic is 5668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey... i have a very strange problem... i am trying to put multiple "plants" on the screen at once. i have a function that gets the x and z coords you put in and finds the y coord on a heightmap and then adds 30(the height of the plant). it takes those coords and draws a transarent quad with a plant texture on it. here is the code: GLvoid drawBush(float x, float z){ glPushMatrix(); glEnable(GL_BLEND); glTranslatef(x,Height(g_HeightMap,x, z )+25,z); glRotatef(yrot,0,1,0); glBindTexture(GL_TEXTURE_2D,texture[2]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3f(15,30,0); glTexCoord2f(0.0f, 1.0f); glVertex3f(-15,30,0); glTexCoord2f(0.0f, 0.0f); glVertex3f(-15,0,0); glTexCoord2f(1.0f, 0.0f); glVertex3f(15,0,0); glEnd(); glPopMatrix(); } i call the function sevral times to make sevral different plants like this: drawBush(100.0f,100.0f); drawBush(130.0f,130.0f); drawBush(130.0f,160.0f); drawBush(160.0f,160.0f); but when i do that, the plants seem to be transparent and solid at the same time?! to see what i mean look at this: www.pmanc.0catch.com/plantError.html can someone tell me why this is happening... PS. yes i know... i "borrowed" the plant texture from the fyEngine. i will be getting my own texture shortly...

Share this post


Link to post
Share on other sites
Have a look at this thread.

Note, for your plants I would recommend using alpha test rather than blending (this will fix the funky quad outline artifact and make your plants look solid). Plus, alpha testing is a bollockload faster than blending

[edited by - Bad Monkey on June 5, 2002 8:40:30 PM]

Share this post


Link to post
Share on other sites
Either depth-sort your sprites, or use alpha masking (which it looks like is what you really want here, anyway) instead of blending.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack

Share this post


Link to post
Share on other sites
BMPs don''t have an alpha channel, but you could add one. If you want plants then choose some color like bright red to be transparent. When you load the image data make a new array and copy it there but create an alpha channel setting the alpha to 1 when the color isn''t bright red, and 0 when it is.

Share this post


Link to post
Share on other sites