Jump to content
  • Advertisement

Archived

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

DKiddie

Blending + Reversing the Rendering Order Table

This topic is 5324 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, Im currently got a bug in a procedurally generated terrain model im making. Im using masking/blending for billboarded trees the problem is that my trees are semi transparent. As a result things are drawing in the wrong order - Ie not in painters order. Heres my code can anyone see any obvious errors Cheers Guys Doug ************************************************************** void DrawBillBoardTree(int x) { int PosX = trees[x].x; int PosZ = trees[x].y; static int flag = 0; static Vector pos; glPushMatrix(); // TRANSLATION PUSH // // Move Tree Appropraitely glTranslatef(PosX - TERR_HALF_SIZE, ground.h.s[PosX][PosZ], PosZ - TERR_HALF_SIZE); // Modelview matrix manipulation CylindricalBillboardEffectBegin(); glEnable(GL_BLEND); // Blend Screen Color With Zero (Black) glBlendFunc(GL_DST_COLOR, GL_ZERO); // select the treemask texture glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D, texture[TREE_MASK]); // select the tree texture glActiveTextureARB(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_2D, texture[TREE]); // draw all trees //////////////////////// glBegin(GL_QUADS); // bottom left corner glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0 ); glVertex3f ( -1, 0, 0 ); // bottom right corner glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0 ); glVertex3f ( 1, 0, 0 ); // top right corner glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0 ); glVertex3f ( 1, 2, 0 ); // top left corner glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 1.0 ); glVertex3f ( -1, 2, 0 ); glEnd(); ////////////////////////////////////////// // Copy Image 2 Color To The Screen glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE); // draw all trees //////////////////////// glBegin(GL_QUADS); // bottom left corner glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0 ); glVertex3f ( -1, 0, 0 ); // bottom right corner glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0 ); glVertex3f ( 1, 0, 0 ); // top right corner glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0 ); glVertex3f ( 1, 2, 0 ); // top left corner glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0 ); glVertex3f ( -1, 2, 0 ); glEnd(); ////////////////////////////////////////// glPopMatrix(); // CylindricalBillboardEffectBegin glPopMatrix(); // TRANSLATION PUSH glEnable(GL_DEPTH_TEST);// Enable Depth Testing glDisable(GL_BLEND); } // end DrawTree()

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
screenshot?

Share this post


Link to post
Share on other sites
Heres a screenshot of my problem, The order of depth should show
from the front a really nasty billboarded tree (what can i say im no artist :D) followed by a Proceduarlly generated polygon tree another billboard then a final procedurally generated tree at the back

http://www.geocities.com/dougkiddie/screenshot.bmp

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!