Blending + Reversing the Rendering Order Table

Started by
2 comments, last by DKiddie 20 years, 2 months ago
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()
Advertisement
screenshot?
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
just enable depth testing..
---sorry for not using proper english , I'm from latin roots

This topic is closed to new replies.

Advertisement