Advertisement

solid transparency

Started by June 05, 2002 07:02 PM
3 comments, last by PmanC 22 years, 8 months ago
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...
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]
Advertisement
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
-----------------------"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
can i alfa mask bmp''s? i knoiw i can do it with tga''s but i am using bmp''s for this project... -PmanC
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.

This topic is closed to new replies.

Advertisement