Vertex-buffer problems

I am running into vertex-buffer problems, as a result of many (incl. some polygon-heavy) objects in my scene. As my concept relies on such complexity, I am trying to find the best solution for ‘turning’ them on and off in the least frameflow-disturbing way during execution. Already I have noticed that using camera-movement and shifts is/are very heavy (movement probarbly due to the object-to-world translation etc).

Anyway; Cameras also becomes relevant within my ‘turn on/off’ challenges/issues:

  1. For now I aim to use ‘frustrum cullying off’, which eases rendering at camera-shifts (I know that it creates larger loading time in the start - but still best tradeoff for my concept)
  2. Also for now, I use ‘.enabled = true/false’ on objects for turning off/on.

But my main challenge is how Playcanvas uses the OpenGL rendering. If I use layers to turn objects on/off instead, will I then get a better flow than 2) due to better/faster object rendering (OpenGL handling).

Hi @Thomas_Due_Nielsen,

When you say you are running into vertex-buffer problems, can you elaborate?

High/problematic VRAM usage, draw calls or polycount etc.

The vertex buffers on initialization are getting uploaded to the GPU and rest in the video memory. When the Playcanvas renderer receives a command to render a model, it will use that already uploaded vertex buffer to prepare the draw call.

If the object isn’t visible (e.g. by frustum culling) or you disable its layer then it won’t be rendered, no draw calls issued. But the mesh vertex buffer will remain in VRAM.

You can unload it from VRAM by calling the asset.unload() method, which will free the memory occupied. Just make sure when your model is rendered again to reload it back in place. This process can stall the GPU a bit though, so be careful of any lag you introduce by doing this.

1 Like

Yeah its all about understanding - so far I am getting deeper into how Playcanvas executes things (theoretically)

In pracsis:
… will try and take a look at the asset.unload() method/approach - but maybe not for while (holidays) - in other words; lets see if your answer [SOLVES] it then :slight_smile:

1 Like

I also recommend installing SpectorJS if you want to dig deeper into the render calls: https://spector.babylonjs.com/

3 Likes

Somehow I got to bypass my bugged master-version (restored a checkpoit etc. ), and made it work - but will for sure get back to this option in case I need to :slight_smile: … thx anyway @Leonidas

1 Like