Recent

Author Topic: How to calculate which cube sides to cull?  (Read 1112 times)

deadbeef

  • New Member
  • *
  • Posts: 17
How to calculate which cube sides to cull?
« on: February 20, 2022, 04:55:30 pm »
I have all my cube faces sorted by (+X -X +Y -Y +Z -Z) in a single ibo and render them using glMultiDrawElements which allows me to select which sides to draw but I can't seem to find a way to select which faces I need.
The values involved should be the cameras position and viewing angle in combination with the chunks center position but how to calculate this exactly?
This would only need to work from outside the chunk but having something that works inside as well would be nice too.

ChrisR

  • Full Member
  • ***
  • Posts: 240
Re: How to calculate which cube sides to cull?
« Reply #1 on: February 28, 2022, 05:21:55 am »
The triangle winding order defines the front versus back face. The default is counter clockwise.
  https://www.khronos.org/opengl/wiki/Face_Culling
Here are a couple of Lazarus demos (meshProj_gl.lpi and cube_gl.lpi are the OpenGL variant, the other projects use Metal).
  https://github.com/neurolabusc/Metal-Demos/tree/master/mesh
and
  https://github.com/neurolabusc/Metal-Demos/tree/master/cube

Mathias

  • Jr. Member
  • **
  • Posts: 78

 

TinyPortal © 2005-2018