如何將視頻輸入附加到SceneKit中的SCNProgram?SCNProgram - 視頻輸入
,不使用自定義程序,我可以這樣做:
func set(video player: AVPlayer, on node: SCNNode) {
let size = player.currentItem!.asset.tracks(
withMediaType: AVMediaTypeVideo).first!.naturalSize
let videoNode = SKVideoNode(avPlayer: player)
videoNode.position = CGPoint(x: size.width/2, y: size.height/2)
videoNode.size = size
let canvasScene = SKScene()
canvasScene.size = size
canvasScene.addChild(videoNode)
let material = SCNMaterial()
material.diffuse.contents = canvasScene
node.geometry?.materials = [material]
}
這使得視頻到SKScene
並使用它作爲一個SCNMaterial
的輸入。
我想在節點上使用SCNProgram
,但我無法弄清楚附加播放器輸入。我不介意解決方案是否不使用中間渲染。如果有可能沒有,它聽起來會更好。
爲什麼用OpenGL標記標記?有什麼特定於你的問題的OpenGL? – thokra
通常涉及很多圖形事物,如緩衝區綁定,尤其是視頻。我目前正在看這個代碼片段:https://github.com/asymptotik/asymptotik-rnd-scenekit-kaleidoscope/blob/01b58ed87a33c6353a398ab0bf77686e2ec96644/Atk_Rnd_VisualToys/VideoCaptureBuffer.swift#L121-L218,它使用了大量的opengl術語。但如果你認爲有更合適的標籤,lmk – Guig