Iphone iOS OpenGL ES 2.0多织物贴花是半透明的
我有一个函数,可以添加我映射纹理的公告牌四边形。该纹理在旋转时围绕3D球体移动。我的drawInRect如下所示:Iphone iOS OpenGL ES 2.0多织物贴花是半透明的,iphone,ios,opengl-es,opengl-es-2.0,glkit,Iphone,Ios,Opengl Es,Opengl Es 2.0,Glkit,我有一个函数,可以添加我映射纹理的公告牌四边形。该纹理在旋转时围绕3D球体移动。我的drawInRect如下所示: - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { // Clear the buffer and prepare to draw glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFF
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
// Clear the buffer and prepare to draw
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Enable the Earth texture
self.effect.texture2d0.name = _earthInfo.name;
self.effect.texture2d0.target = _earthInfo.target;
// Bind the earth vertex array
glBindVertexArrayOES(_earthVertexArray);
// Render the object with GLKit
[self.effect prepareToDraw];
// Draw elements from the index array and uv / vertex / normal info
glDrawElements(GL_TRIANGLES,Earth_polygoncount*3,GL_UNSIGNED_SHORT,0);
// Draw the SkyBox -- Draw skybox centered on eye position
// _skyboxEffect.center = _eyePosition;
// _skyboxEffect.transform.projectionMatrix = self.effect.transform.projectionMatrix;
// _skyboxEffect.transform.modelviewMatrix = self.effect.transform.modelviewMatrix;
// [_skyboxEffect prepareToDraw];
// [_skyboxEffect draw];
// Turn on Blending before displaying satellites
// so that the satellite image ( which has alpha )
// shows up OK
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// Now billboard something
[self createBillboardAtLat:35 andLon:-97];
// Now billboard something
[self createBillboardAtLat:0 andLon:0];
// Now billboard something
[self createBillboardAtLat:-65 andLon:-137];
}
在createBillboardAt函数中,我绘制如下:
// Create a billboard that always faces the camera
- (void)createBillboardAtLat:(float)lat andLon:(float)lon {
... Do stuff ....
// Assign the new matrix to draw with - no translation
self.effect.transform.modelviewMatrix = noTranslationInfo;
// Render the object with GLKit
[self.effect prepareToDraw];
// Draw elements from the index array and uv / vertex / normal info
glDrawElements(GL_TRIANGLES,Billboard_polygoncount*3,GL_UNSIGNED_SHORT,0);
// Restore the original matrix
self.effect.transform.modelviewMatrix = originalMat;
}
在添加广告牌之前,我打开了混合功能,但在某些方向上,hte卫星的纹理与地球很好地混合,但彼此之间没有。请看截图。。。我做错了什么
我已经尝试了所有这些选择,但都没有成功——只有一颗(最前面的)卫星使其他卫星中的一颗黯然失色——不是两颗都有。请帮忙
// Turn on Blending before displaying satellites
// so that the satellite image ( which has alpha )
// shows up OK
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
//glEnable(GL_DEPTH_TEST);
//glDepthFunc(GL_LEQUAL);
//glDepthMask(true);
看起来像深度缓冲区问题。也许上图中较小的卫星绘制得较晚,但深度较远?您的混合函数似乎与您尝试制作的有点不符。。请尝试将其切换为glBlendFunc(GL_SRC_ALPHA,GL_ONE_减去GL_SRC_ALPHA);并报告问题是否已解决。否更改为:glBlendFunc(GL_SRC_ALPHA,GL_ONE_减去_SRC_ALPHA);没有解决问题。你们还有其他想法吗?