Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Rendering slow when getting close to entities

  1. #1
    Newbie Newbie
    Join Date
    May 2018
    Posts
    2

    Rendering slow when getting close to entities

    Hi, I'm am fairly new to OpenGL and trying to make a game engine in c++ and GLFW right now. I managed to import models using Assimp and store them in VAOs/VBOs. I also introduced an fps camera and entities with their own positions in the world. I draw triangles using glDrawElements. The first problem is: when I walk really close to 3D models like a house or a tree, the game starts lagging HARD until I walk away from that entity. This happens for virtually every single entity, even a simple stall model. I checked and the problem isn't with textures as the problem occurs when there are no textures as well. Also, another problem is that my engine cannot render more than around 10000 triangles, it gets really slow, I assume it is from enefficient calls of binding and unbinding VAOs for each entity. What can I do to stop the lag near models and get my engine to render more triangles than 20000?
    I also noticed that my GPU usage is around 99% and when I get close to entities, it spikes up to 100%.
    CPU usage is around 30%.
    Last edited by FlareFlax; 05-12-2018 at 09:17 AM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,359
    You really haven't provided enough information for us to do more than guess. You at least need to tell us something about how you're rendering besides just using glDrawElements. Are you rendering the same number of draw calls close and far (how many)? The same number of triangles close and far (i.e. not using geometry LODs)? The same number of state changes close and far? Is your fragment shading really, really expensive? If you run a CPU profiler, where is all your time being spent? Are you re-creating and/or re-setting up state that should already be setup (and thus is a waste of time)?

    Do some strategic modification to your source code to isolate the cause of the performance bottleneck. Start with something minimal that works and gradually re-enable things until your problem appears.

  3. #3
    Newbie Newbie
    Join Date
    May 2018
    Posts
    2
    Thanks for the tips. I have a class Entity that contains the id of the vao, texture id, and position/rotation/scale.
    I have a vector that stores all entities and every frame in the main loop I render each entity in the vector with glDrawElements.
    Everything runs normally until an entity is right up to the camera.
    Another weird thing is that I have an identical engine, but in Java, and the Java engine runs twice as fast with more fps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •