3

I'd like to know what's the most efficient way of doing frustum culling using the programmable pipeline. I mean, if I understand correctly, following the method described here: Geometric Aproach (by the way the only method described there that worked for me some time ago), functions like glGetFloatv(GL_MODELVIEW_MATRIX, ...) are not valid anymore, as the final vertex position is computed in shader stage. Do I have to compute the frustum planes on the client side for every bounding box transformation I have to check before rendering?

Thanks.

NapardBlose
  • 102
  • 9

1 Answers1

1

The idea of frustum culling is to prevent polygons from being sent to the GPU in the first place, those polygons you already know that will be culled after the vertex shader. So idea is to prevent the vertex shader from transforming those polygons. Using shaders or not, the best way is to keep track of the frustum planes on client side, and traverse the scene graph (could be hierarchical tree or just a list) and cull objects that lay outside the frustum, and don't use glGetFloatv or it's equivalent it is not efficient as it will copy the data from the GPU. You can use feedback buffers instead.

concept3d
  • 2,248
  • 12
  • 21
  • Thanks for the tip. I'm already tracking the frustum planes on client side, but again, following the culling method described above, I need the final modelview matrix to feed the algorithm, that matrix is unique for every model, and its final value is computed in the vertex shader, so it seems that I have to recompute the frustum for every model I have to check, before shader invocation, even if the camera has not moved at all. Am I missing something? Because this doesn't sound logical to me. Thanks in advance. – NapardBlose Feb 08 '16 at 20:39
  • You have to keep track of the transformations for each object, and compute the modelview matrix on the client side and apply frustum culling, this way you avoid getting the matrix from the GPU every time. I don't know what you feed your shaders now, but you can compute the modelview matrix on the CPU and pass it to the shader. – concept3d Feb 09 '16 at 09:26
  • That's what I'm doing actually, it seems that I'm on the right path, thanks!! – NapardBlose Feb 09 '16 at 15:28