是否可以在顶点着色器中访问多边形中的所有顶点?
我正在尝试在 Unity 中创建线框顶点/片段着色器。根据本文,这似乎是可能的。一般的想法似乎是,将顶点着色器中计算的距离向量传递给片段着色器中的每个片段,它可以使用它来根据线框线在多边形内的位置确定绘制线框线的亮度。
不过,从我读过的其他内容来看,您似乎只能访问顶点着色器中的单个顶点。我需要访问 ecah 顶点的多边形中的所有相邻顶点。该论文似乎暗示几何着色器不是必需的,这很好,因为 Unity 还不支持它们。
我缺少什么?是否永远不可能在顶点着色器中访问相邻顶点?如果没有几何着色器,我想要做的事情是不可能的吗?
I'm trying to create a wireframe vertex/fragment shader in Unity. It seems possible according to this paper. The general ideas seems to be that you pass a distance vector calculated in the vertex shader to each fragment in the fragment shader, which it can use to determine what brightness to draw the wireframe line at based on its position within a polygon.
From everything else I've read, though, it appears that you only get access to a single vertex in a vertex shader. I would need access to all of the neighbouring vertices in a polygon for ecah vertex. The paper seems to imply that a geometry shader is not necessary, which is good because Unity doesn't support them yet.
What am I missing? Is it never possible to access neighbouring vertices in a vertex shader? Is what I'm trying to do impossible without geometry shaders?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你似乎确实已经读完了 2.1 中的段落:
因此,当不使用几何着色器时,您确实不知道三角形的其他顶点,因此必须将它们作为附加顶点属性进行传输。因此,对于三角形的每个顶点,您都会获得两个额外的 vec3 属性,其中包含该三角形的其他两个顶点的位置。当然,就像文本所说,您不能使用索引绘图,因为这两个属性不仅取决于顶点位置,还取决于该顶点所属的三角形。
You seem to indeed have over-read the paragraph in 2.1 that says
So when not using the geometry shader you indeed don't know the other vertices of a triangle and therefore have to transmit them as additional vertex attributes. So for each vertex of a triangle you got two additional vec3 attributes containing the positions of the other two vertices of this triangle. And of course, like the text says, you cannot use indexed drawing, since those two attributes don't only depend on the vertex position, but also on the triangle this vertex belongs to.