gpt4 book ai didi

ios - 在 Swift ARKit 中显示多行文本时缓冲区导致先前/过多的 GPU 错误

转载 作者:可可西里 更新时间:2023-11-01 01:07:33 25 4
gpt4 key购买 nike

我正在构建一个应用程序,我想在我的目标增强图像上显示多行文本。该程序在文本少于 7 行时运行良好,但在超过 7 行时崩溃。我还注意到,如果一行太长,同样的错误“命令缓冲区的执行由于执行期间的错误而中止。被忽略(导致先前/过多的 GPU 错误)”也会出现。

    let text = SCNText(string: "this is the first line  \n hello this is the second line \n hello this is the third line \n hello this is the fourth line \n hello this is the fifth line \n hello this is the sixth line \n hello this is the seventh line \n hello this is the eigth lines\n " , extrusionDepth: 0.1)

//setting the basic properties of text

text.font = UIFont.systemFont(ofSize: 1)
text.flatness = 0.005
text.isWrapped = true
let textNode = SCNNode(geometry: text)
let fontScale: Float = 0.01
textNode.scale = SCNVector3(fontScale, fontScale, fontScale)

//设置文字在图片上方居中并面向摄像头

    textNode.eulerAngles.x = -.pi/2
centerNode(node: textNode)

//self.sceneView.scene.rootNode.addChildNode(planeNode)
// the text will be centered right above the image
node.addChildNode(textNode)
// create a plane node as the background of the text
let textWidth = text.boundingBox.max.x - text.boundingBox.min.x
let textHeight = text.boundingBox.max.y - text.boundingBox.min.y
let plane = SCNPlane(width: CGFloat(textWidth), height: CGFloat(textHeight))
plane.firstMaterial?.transparency = 0.5
plane.firstMaterial?.diffuse.contents = UIColor.black
let planeNode = SCNNode(geometry: plane)

planeNode.position = SCNVector3(textWidth/2,1.5*textHeight,-0.0001)
textNode.addChildNode(planeNode)

“命令缓冲区的执行由于执行期间的错误而中止。忽略(导致先前/过多的 GPU 错误)”

最佳答案

当我的文本过于复杂时,我遇到了这个问题。我通过增加 SCNTextflatness 减少了多边形的总数,并且能够呈现更多文本。

text.flatness = 0.6    // default value
text.flatness = 0.0005 // more polygons, higher complexity
text.flatness = 1.0 // lower polyon, lower complexity (uglier text)

尝试降低复杂性。光照、多边形总数、 Material 复杂度等。

关于ios - 在 Swift ARKit 中显示多行文本时缓冲区导致先前/过多的 GPU 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54559925/

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