0
沒有glFog,我的透明PNG顯示很好,但是用它你可以看到矩形背景和其他顏色的條紋(注意其他污垢材料按預期工作,但不使用PNG或透明度)。glFog導致透明PNG失去透明度
alt text http://img203.imageshack.us/img203/4466/screenshot20100509at528.pngalt text http://img69.imageshack.us/img69/3131/screenshot20100509at456.png
這裏是我的霧代碼:
GLfloat colour[4]={0.8f,0.8f,1.0f, 1.0f};
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, colour);
glFogf(GL_FOG_DENSITY, 0.1);
glHint(GL_FOG_HINT, GL_NICEST);
glFogf(GL_FOG_START, 1.0);
glFogf(GL_FOG_END, 5.0);
glEnable(GL_FOG);
glClearColor(0.8f,0.8f,1.0f,1.0f);
而且我對PNG代碼:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLfloat myAmbient[] = {0.7,0.7,0.7,1.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, myAmbient);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, plantTexture);
glColor3f(0.5,0.5,0.2);
glPushMatrix();
glTranslated(-1,-14,10);
glScaled(10,10,10);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glTexCoord2f(0,1); glVertex2i(1,0);
glNormal3f(0,0,1);
glTexCoord2f(0,0); glVertex2i(1,1);
glNormal3f(0,0,1);
glTexCoord2f(1,0); glVertex2i(0,1);
glNormal3f(0,0,1);
glTexCoord2f(1,1); glVertex2i(0,0);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
我完全失去了在這一個。有任何想法嗎?
有些問題:你在什麼順序中畫東西?你使用阿爾法測試嗎? png透明部分的顏色是什麼樣的?如果將alpha = 0用於霧色,會發生什麼情況? – Bahbar 2010-05-12 12:37:40