删除边缘边框中的拼接线

删除边缘边框中的拼接线

本文介绍了SceneKit - 删除边缘边框中的拼接线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在立方体上显示纹理(参见

知道如何摆脱它吗?输入纹理看起来像

因此输入中存在一些不连续性.我正在使用自定义的 SceneKit 几何图形,它除了将此纹理映射到立方体之外并没有做更多的事情.你可以找到上面提到的相关代码:

使边缘消失(假设相机在里面).结果,纹理被裁剪了一点,但这不太明显.

我曾经将 3 x 8 顶点的位置定义为:

let _positions = [SCNVector3(x:-halfSide, y:-halfSide, z: halfSide),SCNVector3(x: halfSide, y:-halfSide, z: halfSide),SCNVector3(x:-halfSide, y:-halfSide, z:-halfSide),SCNVector3(x: halfSide, y:-halfSide, z: -halfSide),SCNVector3(x:-halfSide, y: halfSide, z: halfSide),SCNVector3(x: halfSide, y: halfSide, z: halfSide),SCNVector3(x:-halfSide, y: halfSide, z: -halfSide),SCNVector3(x: halfSide, y: halfSide, z: -halfSide),]让仓位 = _positions + _positions + _positions

现在我将最后一行替换为:

让 X = 0让 Y = 8让 Z = 16func killEdgeStitching(位置:[SCNVector3],轴:Int)->[SCNVector3] {var res = [SCNVector3]()让 delta = 浮点数(0.99)对于位置{var newPosition = SCNVector3(x: pos.x, y: pos.y, z: pos.z)切换轴{案例十:newPosition.x *= delta案例 Y:newPosition.y *= delta默认:newPosition.z *= delta}res.append(newPosition)}返回资源}让位置 = killEdgeStitching(positions: _positions, axis: X) +killEdgeStitching(位置:_positions,轴:Y)+killEdgeStitching(位置:_positions,轴:Z)

我会把它放在那里,但希望有人会有真正的答案!

I'm displaying a texture on a cube (see SceneKit - Map cube texture to box)Things work well now, but the result show a light stitching line between some of the cube faces that I outlined here (you are inside the cube):

Any idea how I can get rid of that? The input texture looks like

So there is some discontinuity in the input. I'm using a custom SceneKit geometry that doesn't do much more than mapping this texture to a cube. You can find the relevant code in question mentioned above:

So that the edges disappear (assuming the camera is inside). The texture is cropped a bit as a result, but this is much less noticeable.

I used to define the position of the 3 x 8 vertices as:

let _positions = [
  SCNVector3(x:-halfSide, y:-halfSide, z:  halfSide),
  SCNVector3(x: halfSide, y:-halfSide, z:  halfSide),
  SCNVector3(x:-halfSide, y:-halfSide, z: -halfSide),
  SCNVector3(x: halfSide, y:-halfSide, z: -halfSide),
  SCNVector3(x:-halfSide, y: halfSide, z:  halfSide),
  SCNVector3(x: halfSide, y: halfSide, z:  halfSide),
  SCNVector3(x:-halfSide, y: halfSide, z: -halfSide),
  SCNVector3(x: halfSide, y: halfSide, z: -halfSide),
]
let positions = _positions + _positions + _positions

and now I'm replacing the last line by:

let X = 0
let Y = 8
let Z = 16
func killEdgeStitching(positions: [SCNVector3], axis: Int) -> [SCNVector3] {
  var res = [SCNVector3]()
  let delta = Float(0.99)
  for pos in positions {
      var newPosition = SCNVector3(x: pos.x, y: pos.y, z: pos.z)
      switch axis {
      case X:
          newPosition.x *= delta
      case Y:
          newPosition.y *= delta
      default:
          newPosition.z *= delta
      }
      res.append(newPosition)
  }
  return res
}
let positions = killEdgeStitching(positions: _positions, axis: X) +
  killEdgeStitching(positions: _positions, axis: Y) +
  killEdgeStitching(positions: _positions, axis: Z)

I'll leave that out there, but hopefully someone will have a real answer!

这篇关于SceneKit - 删除边缘边框中的拼接线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 17:36