2017-03-09 12 views
0

enter image description here enter image description hereOpenglESアルファテクスチャ深さ

glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT); 

glUseProgram(_program); 
GLKVector2 poz= { 0, 0}; 
if (_Sprite2) 
{ 
    float aspect = (GLfloat) _screenWidth/ (GLfloat) _screenHeight; 
    [self esMatrixLoadIdentity : &perspective]; 
    [self esPerspective:&perspective pos_fovy:60.0f pos_aspect:aspect pos_nearZ:1.0f pos_farZ:30.0f]; 


    [self esMatrixLoadIdentity : &modelview]; 
    [self esTranslate : &modelview trans_x:0.0f trans_y:-0.5f trans_z:-5 ]; 
    [self esRotate : &modelview gl_angle:0.0f _x:1.0 _y:0.0 _z:1.0]; 
    [self esMatrixMultiply :&mvpMatrix src_A:&modelview src_B:&perspective]; 

    glUniformMatrix4fv (mvpLoc, 1, GL_FALSE, (GLfloat*) &mvpMatrix.m[0][0]); 

    [_Sprite2 update : poz]; 
    [_Sprite2 draw]; 
}/// crown 

if(_sprite)//bug 
{ 
    float aspect = (GLfloat) _screenWidth/ (GLfloat) _screenHeight; 
    [self esMatrixLoadIdentity : &perspective]; 
    [self esPerspective:&perspective pos_fovy:60.0f pos_aspect:aspect pos_nearZ:1.0f pos_farZ:30.0f]; 

    [self esMatrixLoadIdentity : &modelview]; 
    [self esTranslate : &modelview trans_x:0.0f trans_y:0.0f trans_z:_zPoz + _zPoz_2]; 
    [self esRotate : &modelview gl_angle:0.0f _x:1.0 _y:0.0 _z:1.0]; 

    [self esMatrixMultiply :&mvpMatrix src_A:&modelview src_B:&perspective]; 

    glUniformMatrix4fv (mvpLoc, 1, GL_FALSE, (GLfloat*) &mvpMatrix.m[0][0]); 

    [_sprite update : poz]; 
    [_sprite draw]; 
} 

バグ画像が変化奥行き-Z、 とクラウンの透明領域が正しく働いています。

どのようにしてバグの背後に正しく表示されますか?

答えて

0

次のいずれかを行う必要があります。

  1. ソートあなたのスプライト彼らはデプステストを行わずに後ろから前にレンダリングし、ちょうどOHPフィルムを提供するために、ブレンドに依存しているので。
  2. に透明なフラグメントをドロップするようにフラグメントシェーダにアルファテストを追加します(例えばif (alpha < 0.05) discard;、必要に応じて透明度のしきい値を調整する)
+0

はよく働い二答えてくれてありがとう。私はそれを避けたい – nosweet

関連する問題