많은 입자에 대한 모든 정점 데이터를 단일 배열로 결합했습니다. 고유 한 번역을 유지하는 방식으로 모든 입자를 일괄 처리하는 방법은 무엇입니까?OpenGL ES 2.0 - 고유 한 변환, 회전, 비율 및 알파가있는 입자를 일괄 처리하는 방법은 무엇입니까?
나는 이것을 어떻게하는지 혼란 스럽다. 이미이 문제에 대한 두 개의 게시물을 작성했지만 여전히 혼란 스럽습니다.
- OpenGL ES - How to Batch Render 500+ particles w/ different alphas, rotations, and scales? : 저는 현재 두 개의 게시물이 등
- How do I draw 1000+ particles (w/ unique rotation, scale, and alpha) in iPhone OpenGL ES particle system without slowing down the game?
을의 OpenGL ES 1.1을 사용하지만 내가 실제로 유일한 번역, 회전과 입자의 배치 렌더링을 수행 할 수 있음을 의미하는 경우 2.0으로 업그레이드 기꺼이하고
모두 높은 수준의 접근 방식을 설명,하지만 난 입자의 배치를 렌더링하는 방법을 을 알 필요가 어디에서 각 입자의 이동, 회전, 스케일은 모든 프레임으로 바뀝니다. 귀하의 답변이 CPU에서 번역을 계산하는 것이라면, 그 예를 보여주십시오.
현재 구현시 Vertex Array Objects를 사용하고 있습니다. 최상의 성능을 위해 VBO를 사용해야합니다. VBO를 구현 하겠지만, 먼저 배치를 구현하고 싶습니다. 성공적인 일괄 처리가 완료되면 VAO를 VBO로 변경합니다. 따라서이 질문의 초점은 VAO로이를 수행하는 방법입니다.
여기에 배치하기 전에 내 코드가 있었는데, 모델 뷰 매트릭스에서 새 행렬을 삽입하고, 렌더링되고있는 현재 액터에 따라 번역, 회전, 크기 조절 및 알파를 적용하고 현재 액터의 정점과 텍스처 코드를 그립니다. 렌더링 :
glPushMatrix();
glTranslatef(translation.x, translation.y, translation.z);
// rotation
glRotatef(rotation.x, 1, 0, 0);
glRotatef(rotation.y, 0, 1, 0);
glRotatef(rotation.z, 0, 0, 1);
// scale
glScalef(scale.x, scale.y, scale.z);
// color and alpha
glColor4f(1.0, 1.0, 1.0, alpha);
glVertexPointer(2, GL_FLOAT, 0, aSprite.vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texturedQuad.textureCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
을 지금, 나는이 배치 배열에 모든 입자 배우의 정점과 textureCoords를 조합 한 것을 주어, 나는 그의 정점과 textureCoords를 모델 뷰 행렬에 새로운 매트릭스를 밀어 그릴 싶습니다 적절한 번역, 회전, 축척, 알파 등의 액터 ...
그래서 내
static GLFloat verticesBatched[appropriate_length] = ...; // I have a method to populate this array based on the Actors to render
static GLFloat textureCoordsBatched[appropriate_length] = ...; // I have a method to populate this array based on the Actors to render
glPushMatrix();
// perform CPU matrix manipulation to manually translate, rotate, and scale all vertices
glVertexPointer(2, GL_FLOAT, 0, verticesBatched);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordsBatched);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
유효한 대답은 명확하게이 문제에 대한 해결책을 설명하는 코드 예제 하나입니다 : 추측은 같은 soemthing을 보일 것입니다.