简体   繁体   English

细分级别> 0的SceneKit节点中不需要的伪像

[英]Unwanted artefacts in SceneKit nodes with subdivisionLevel > 0

Ok, the code for this was quite long and complex so I'm going to have to describe this problem carefully. 好的,这的代码很长很复杂,所以我将不得不仔细地描述这个问题。

Imagine you are creating a 3D object by lathing a set of points around an axis. 想象一下,您是通过围绕轴线车削一组点来创建3D对象的。 You now want to generate a spherical texture map for these points. 现在,您要为这些点生成球形纹理贴图。 There is now a difficult dichotomy: 现在有一个困难的二分法:

If you create a fully cyclical mesh, where the last points are joined to the first points and there are no edges that are not shared by two polygonal facets, then you cannot create a true spherical map. 如果创建一个完全循环的网格,其中最后一个点与第一个点相连,并且没有两个多边形小面不共享的边,则无法创建真正的球形贴图。 This is because vertices are mapped 1:1 with texture points. 这是因为顶点与纹理点的比例为1:1。 The leftmost vertex of the first facet would need to map to a U value of 0; 第一个构面的最左侧顶点将需要映射为U值0; the rightmost vertex of the last facet would map to 1 - but these are the same vertex! 最后一个构面的最右边顶点将映射为1-但是这些顶点是相同的! The result is that one segment of the mesh is textured with a large portion of the texture map from right to left, whereas all others map from left to right correctly. 结果是,网格的一个部分从右到左都带有大部分纹理贴图,而所有其他部分都正确地从左到右贴图。

纹理映射不正确

You could theoretically solve this by duplicating the first set of vertices so that they can have different texture coordinates depending on which polygon they relate to, but this surfaces another problem. 从理论上讲,您可以通过复制第一组顶点来解决此问题,以使它们可以具有不同的纹理坐标,具体取决于它们所涉及的多边形,但这会带来另一个问题。 If I do this and apply a subdivision level to the resulting geometry, an ugly crease appears and the texture seems badly distorted. 如果执行此操作并将细分级别应用到生成的几何图形,则会出现难看的折痕,并且纹理似乎严重变形。 It's not so obvious on a still image, but look in the bottom right of the image. 在静止图像上不是很明显,但是请看图像的右下角。

讨厌的“捏”

Ideally I would like to be able to apply a texture map AND subdivision to the same mesh without experiencing these ugly effects. 理想情况下,我希望能够将纹理贴图和细分应用于相同的网格,而不会遇到这些难看的效果。 Anybody got any ideas? 有人有想法吗?

The crease in the subdivided model is standard subdivision behavior after duplicating those vertices. 细分模型中的折痕是复制这些顶点后的标准细分行为。 In fact, it's what I and many other 3D modellers do to create creases (opposed to the edge and vertex crease options even scenekit supports). 实际上,这就是我和许多其他3D建模人员所做的创建折痕的步骤(与场景工具箱支持的边缘和顶点折痕选项相对)。 So even though they are “unwanted” by you, it's expected behavior. 因此,即使您对它们“有害”,这也是预期的行为。

Imagine you are creating a 3D object by lathing a set of points around an axis. 想象一下,您是通过围绕轴线车削一组点来创建3D对象的。 You now want to generate a spherical texture map for these points. 现在,您要为这些点生成球形纹理贴图。

I'm having a hard time imagining why I would want to generate a spherical map for a torus. 我很难想象为什么要为圆环生成球面图。 Spherical mapping is specifically for reflections. 球形映射专门用于反射。

Anyway, the problem is not the subdivision or the map, but the fact you use shared vertices. 无论如何,问题不是细分或地图,而是您使用共享顶点的事实。

but these are the same vertex! 但是这些是相同的顶点!

Right. 对。 Instead of adding extra vertices at just the point where the texture basically repeats, you need to feed unique vertices to the SCNGeometry. 您需要在SCNGeometry中提供唯一的顶点,而不是在基本重复纹理的位置添加额外的顶点。 That way subdivision will work and you can map it as expected. 这样,细分将起作用,您可以按预期进行映射。

Turns out my problem was actually that there were some redundant vertices in the profile I was attempting to rotate and this was just too much for subdivision to cope with. 事实证明,我的问题实际上是我尝试旋转的轮廓中有一些多余的顶点,而这对于细分来说实在是太多了。 After removing these, the subdivision looks just fine - so there's probably just a limit to how complex a raw edge you can have on a model before subdivision packs in. 删除这些后,细分看起来就很好-因此,在细分打包之前,模型上原始边缘的复杂程度可能只是一个限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM