[英]OpenGL, Culling objects that are outside the view
In my case I wanna render 50,000 or more cubes that are distributed randomly inside a large bounding box, I don't want using instancing right now so I have to render each cube, I wanna improve the performance by culling out the cubes that are outside the camera view. 就我而言,我想渲染在一个大边界框中随机分布的50,000个或更多的多维数据集,我现在不想使用实例化,因此我必须渲染每个多维数据集,我想通过剔除外面的多维数据集来提高性能相机视图。 I have a camera class that has two matrices
view
and projection
, each cube has its own bounding box, so I am planning to check each frame if the camera view bounding box contains the center of each cube if yes call its draw function if not ignore it. 我有一个具有两个矩阵
view
和projection
的相机类,每个多维数据集都有自己的边界框,因此我打算检查每个帧,如果相机视图边界框包含每个多维数据集的中心(如果是),请调用其draw函数(如果不忽略)它。
I have for view matrix 3 vectors eye, target and up, and for projection width, height, near, far and FOV. 我有3个向量,分别是眼,目标和上眼,以及投影的宽度,高度,近,远和FOV。
so I have two questions: 所以我有两个问题:
I got an idea from here how_to_check_if_vertex_is_visible_for_user that worked fine with me. 我从这里获得了一个想法, how_to_check_if_vertex_is_visible_for_user对我来说很好用。
multiplying the projection view matrix of the camera by the any point in the 3D space the visible ones should be between [-1,1]. 将相机的投影视图矩阵乘以3D空间中的任意点,可见的点应在[-1,1]之间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.