I ran into a poor performance problem when rendering to OpenGL using Assimp. The scene has 367727 triangles. At the same time, 298084 is a model of chess. I do not think that the problem is in shaders, because:
128x128 window: 44 (43.7657) FPS, 22.849 ms
256x256 window: 42 (40.9563) FPS, 24.4162 ms
512x512 window: 35 (34.8007) FPS, 28.7351 ms
1024x1024 window: 22 (21.084) FPS, 47.4293 ms
But if I don’t draw chess, then in the window 1366x763: 55 (54.8424) FPS, 18.2341 ms
Also, changing the resolution of the shadow map does not greatly affect the FPS.
There are 2 point light sources on the scene, with FPS loss when drawing this model for each of the passes ~10 FPS (from 23 to 55). Ie, there is no difference where I draw this model: in the depth map or in the "color texture". Losses ~ are the same. I load the model with the following parameters: aiProcess_Triangulate | aiProcess_CalcTangentSpace | aiProcess_JoinIdenticalVertices
And render as follows:
inline void pointer(GLint location, int count, GLuint buffer) {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glVertexAttribPointer(
location, // attribute location
count, // count (1, 2, 3 or 4)
GL_FLOAT, // type
GL_FALSE, // is normalized?
0, // step
nullptr // offset
);
}
inline void pointerui(GLint location, int count, GLuint buffer) {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glVertexAttribIPointer(
location, // attribute location
count, // count (1, 2, 3 or 4)
GL_UNSIGNED_INT, // type
0, // step
nullptr // offset
);
}
...
pointer(cs.inPosition, 3, model.shape->meshes[i].getVerticesBuffer());
pointer(cs.inNormal, 3, model.shape->meshes[i].getNormalsBuffer());
pointer(cs.inTangent, 3, model.shape->meshes[i].getTangentsBuffer());
pointer(cs.inBitangent, 3, model.shape->meshes[i].getBitangentsBuffer());
pointer(cs.inTexCoord, 2, model.shape->meshes[i].getTexCoordsBuffer());
if (model.shape->bonesPerVertex != 0) {
pointer(cs.inBoneWeights, 4, model.shape->meshes[i].getBoneWeightsBuffer());
pointerui(cs.inBoneIds, 4, model.shape->meshes[i].getBoneIdsBuffer());
}
modelMatrix = &model.transformation;
updateMatrices();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, model.shape->meshes[i].getIndicesBuffer());
glDrawElements(GL_TRIANGLES, model.shape->meshes[i].indices.size(), GL_UNSIGNED_INT, nullptr)
EDIT: vertex_shader.glsl, fragment_shader.glsl
I apologize that the fragment shader is difficult to read, I have not yet fully completed work on it
My GPU is NVGF 920mx
EDIT: here is capture from renderdoc
for 20 do texture lookup
is a potential culprit, but can't be sure without measuring. Note: textureCubeShadow sampler is dedicated for shadow mapping, so I'm pretty sure you should be using that instead. Not familiar with it personally though. – Andreas