Hello, I have this problem: there is a dynamic scene (the viewpoint changes over time), I display a number of sprites (translucent with texture). If they are all at a fairly close distance from each other (for example, along a chain with a very small step) and I approach one of them (in particular, the first one), then the FPS drops dramatically, the effect is that I look at the hay almost all the sprites at once. Maybe the term multiple mixing here is appropriate? How to get around this place? I turn off the depth test during drawing. If it is left on, the FPS stops falling, but the conclusion of this whole case becomes incorrect. I sort the objects in the hay.

So I calculate the coordinates of the sprite:

double ModelViewMatrix[16]; glGetDoublev(GL_MODELVIEW_MATRIX, ModelViewMatrix); // Построим вектора вверх и вправо Right.x = (float)ModelViewMatrix[0]; Right.y = (float)ModelViewMatrix[4]; Right.z = (float)ModelViewMatrix[8]; Up.x = (float)ModelViewMatrix[1]; Up.y = (float)ModelViewMatrix[5]; Up.z = (float)ModelViewMatrix[9]; // Вычислим четыре координаты спрайта Coo[0].x = (-Right.x-Up.x); Coo[0].y = (-Right.y-Up.y); Coo[0].z = (-Right.z-Up.z); Coo[1].x = (Right.x-Up.x); Coo[1].y = (Right.y-Up.y); Coo[1].z = (Right.z-Up.z); Coo[2].x = (Right.x+Up.x); Coo[2].y = (Right.y+Up.y); Coo[2].z = (Right.z+Up.z); Coo[3].x = (-Right.x+Up.x); Coo[3].y = (-Right.y+Up.y); Coo[3].z = (-Right.z+Up.z); 

So I paint the sprite myself:

 void sprit(float x, float y, float z, float Size, float r, float g, float b, float bind){ forsprit(); glColor4ub(r,g,b,bind); glTranslatef(x,y,z); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(Size*Coo[0].x,Size*Coo[0].y, Size*Coo[0].z); glTexCoord2f(1,0); glVertex3f(Size*Coo[1].x,Size*Coo[1].y, Size*Coo[1].z); glTexCoord2f(1,1); glVertex3f(Size*Coo[2].x,Size*Coo[2].y, Size*Coo[2].z); glTexCoord2f(0,1); glVertex3f(Size*Coo[3].x,Size*Coo[3].y, Size*Coo[3].z); glEnd(); glTranslatef(-x,-y,-z); } 

Well, actually drawing in general

  void star(float x, float y, float z, float Size, float r, float g, float b, int num) { glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[0]); sprit(x,y,z,Size, r*255,g*255,b*255,255); sprit(x,y,z,Size*0.65, 255,255,255,255); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); } 

    1 answer 1

    The conclusion in your case may be incorrect due to incorrect depth setting, or the wrong order of rendering transparent / translucent objects ...

    1. Increase the distance between the sprites.
    2. Modify the OpenGL initialization block.

       gluPerspective( 45.0f, (GLfloat)width/(GLfloat)height,(цифра здесь меньше расстояния между спрайтами) , 100.0f ); 
    • I have more than 1 figure in prospects. 1600/900 and the distance between the sprites is much less than 1 problem is definitely not the case. The conclusion I have is correct with the depth buffer disabled!, That is, the rendering order is correct, there are no problems. The incorrect appearance of the sprites is that they are transparent or not, that is, a square border slips, that is, the border shows the background but repaints the sprite is right behind him and these glitches are random (I emphasize that this is with the depth test turned ON ) (to be continued) - vsegdatrezv
    • continuation - please explain what depth settings? do you mean perspective? I ask it like this gluPerspective (45.0f, (GLfloat) (width) / (GLfloat) (height), 1.0f, 22000); Increasing the distance between the sprites is not possible because their position is the result of the program. Task: modeling the interaction of bodies in space, sprites are responsible directly for the sun. By the way, experience shows that FPS sprites are not necessarily accumulated if one of the sprites is full screen and I look at the stage through it - vsegdatrezv
    • there is a similar situation if someone passes (flies) through a cloud of smoke. (to make it easier to understand the essence of the problem), by the way, to get around the situation when one of the sprites on the whole screen is easily solved, simply to prohibit such a close approximation but nevertheless the problem with the chain cannot be solved because there is no such close approach so that fps will fall CPU with this 3-9%) - vsegdatrezv