我正在寻找一种有效的网格(三角形集合)和圆锥体(由该方向的原点,方向和角度给出)交叉的算法。 更准确地说,我想找到最接近锥体原点的交点。 现在我所能想到的就是将一个网格与来自锥体原点的几条光线相交并获得最近的点。 (当然,将为网格构建一些空间结构以拒绝不必要的交叉点)
我还发现了以下算法的简要描述:“通过用网格绘制锥形几何并读取标记交点的最小深度值,在GPU上计算锥形到网格的交点”。 不幸的是,它的实现对我来说并不明显。
那么有人可以提出比我更高效的东西,或者更详细地解释如何使用OpenGL在GPU上完成它吗?
I am looking for an efficient algorithm for mesh (set of triangles) and cone (given by origin, direction and angle from that direction) intersection. More precisely I want to find intersection point which is closest to the cone's origin. For now all what I can think about is to intersect a mesh with several rays from the cone origin and get the closest point. (Of course some spatial structure will be constructed for mesh to reject unnecessary intersections)
Also I found the following algo with brief description: "Cone to mesh intersection is computed on the GPU by drawing the cone geometry with the mesh and reading the minimum depth value marking the intersection point". Unfortunately it's implementation isn't obvious for me.
So can anyone suggest something more efficient than I have or explain in more details how it can be done on GPU using OpenGL?
最满意答案
在GPU上我会这样做:
设置视图
来自锥体的起源 向外指挥 覆盖bigest圆片 对于无限锥体,使用视图坐标系中网格顶点的最大Z值清除缓冲区
画网
但在片段着色器中只绘制与锥相交的像素 |fragment.xyz-screen_middle|=tan(cone_ang/2)*fragment.z读z缓冲区
读取片段并从有效(填充)中选择最接近锥体原点的片段[笔记]
如果您的gfx引擎也可以处理片段着色器的输出值 然后你可以跳过子弹4并在子弹3内进行最小距离搜索而不是渲染...... 这将大大加快这个过程(只需要单个xyz矢量)on GPU I would do it like this:
set view
to cones origin directing outwards covering the bigest circle slice for infinite cone use max Z value of mesh vertexes in view coordinate systemclear buffers
draw mesh
but in fragment shader draw only pixels intersecting cone |fragment.xyz-screen_middle|=tan(cone_ang/2)*fragment.zread z-buffer
read fragments and from valid (filled) select the closest one to cones origin[notes]
if your gfx engine can handle also output values from your fragment shader then you can skip bullet 4 and do the min distance search inside bullet 3 instead of rendering ... that will speed up the process considerably (need just single xyz vector)网格和锥体交叉算法(Mesh and cone intersection algorithm)我正在寻找一种有效的网格(三角形集合)和圆锥体(由该方向的原点,方向和角度给出)交叉的算法。 更准确地说,我想找到最接近锥体原点的交点。 现在我所能想到的就是将一个网格与来自锥体原点的几条光线相交并获得最近的点。 (当然,将为网格构建一些空间结构以拒绝不必要的交叉点)
我还发现了以下算法的简要描述:“通过用网格绘制锥形几何并读取标记交点的最小深度值,在GPU上计算锥形到网格的交点”。 不幸的是,它的实现对我来说并不明显。
那么有人可以提出比我更高效的东西,或者更详细地解释如何使用OpenGL在GPU上完成它吗?
I am looking for an efficient algorithm for mesh (set of triangles) and cone (given by origin, direction and angle from that direction) intersection. More precisely I want to find intersection point which is closest to the cone's origin. For now all what I can think about is to intersect a mesh with several rays from the cone origin and get the closest point. (Of course some spatial structure will be constructed for mesh to reject unnecessary intersections)
Also I found the following algo with brief description: "Cone to mesh intersection is computed on the GPU by drawing the cone geometry with the mesh and reading the minimum depth value marking the intersection point". Unfortunately it's implementation isn't obvious for me.
So can anyone suggest something more efficient than I have or explain in more details how it can be done on GPU using OpenGL?
最满意答案
在GPU上我会这样做:
设置视图
来自锥体的起源 向外指挥 覆盖bigest圆片 对于无限锥体,使用视图坐标系中网格顶点的最大Z值清除缓冲区
画网
但在片段着色器中只绘制与锥相交的像素 |fragment.xyz-screen_middle|=tan(cone_ang/2)*fragment.z读z缓冲区
读取片段并从有效(填充)中选择最接近锥体原点的片段[笔记]
如果您的gfx引擎也可以处理片段着色器的输出值 然后你可以跳过子弹4并在子弹3内进行最小距离搜索而不是渲染...... 这将大大加快这个过程(只需要单个xyz矢量)on GPU I would do it like this:
set view
to cones origin directing outwards covering the bigest circle slice for infinite cone use max Z value of mesh vertexes in view coordinate systemclear buffers
draw mesh
but in fragment shader draw only pixels intersecting cone |fragment.xyz-screen_middle|=tan(cone_ang/2)*fragment.zread z-buffer
read fragments and from valid (filled) select the closest one to cones origin[notes]
if your gfx engine can handle also output values from your fragment shader then you can skip bullet 4 and do the min distance search inside bullet 3 instead of rendering ... that will speed up the process considerably (need just single xyz vector)
发布评论