gpt4 book ai didi

shader - 是否可以在顶点着色器中访问多边形中的所有顶点?

转载 作者:行者123 更新时间:2023-12-04 21:22:59 24 4
gpt4 key购买 nike

我正在尝试在 Unity 中创建线框顶点/片段着色器。根据 this paper 似乎可能.一般的想法似乎是将顶点着色器中计算的距离向量传递给片段着色器中的每个片段,它可以使用它来确定根据线框线在多边形内的位置绘制线框线的亮度。

但是,从我读过的所有其他内容来看,您似乎只能访问顶点着色器中的单个顶点。我需要访问 ecah 顶点的多边形中的所有相邻顶点。该论文似乎暗示不需要几何着色器,这很好,因为 Unity 尚不支持它们。

我错过了什么?是否永远无法访问顶点着色器中的相邻顶点?如果没有几何着色器,我尝试做的事情是不可能的吗?

最佳答案

你似乎确实多读了 2.1 中说的段落

Step G1 is generally always performed in the vertex shader. Step G2 should be performed in the geometry shader since the geometry shader has access to all vertices of the polygon (provided it is a triangle). Consequently, if the geometry shader is not used, the vertex shader needs to receive the other vertices as attributes in order to compute the distances. This entails that the application code is not invariant to whether the wireframe method is used, that additional data needs to be transmitted, and, finally, that the use of indexed primitives is precluded since the attributes of a vertex depend on which triangle is drawn.



因此,当不使用几何着色器时,您确实不知道三角形的其他顶点,因此必须将它们作为附加顶点属性进行传输。因此,对于三角形的每个顶点,您会获得两个额外的 vec3 属性,其中包含该三角形其他两个顶点的位置。当然,正如文中所说,您不能使用索引绘图,因为这两个属性不仅取决于顶点位置,还取决于该顶点所属的三角形。

关于shader - 是否可以在顶点着色器中访问多边形中的所有顶点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8915298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com