I have a transparent video that I created as a test. It's an mov file that was exported as HEVC 265, which means it has transparency as a background.
I am using it for VideoMaterial
in RealityKit
, which now has support for transparent videos.
I just loaded it like you would think:
private static var playerLooper: AVPlayerLooper? = nil // property of class
let video = AVURLAsset(url: Bundle.main.url(forResource: "transparentVideo", withExtension: "mov")!)
let playerItem = AVPlayerItem(asset: video)
let queuePlayer = AVQueuePlayer()
playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: playerItem)
let material = VideoMaterial(avPlayer: queuePlayer)
let myMesh = MeshResource.generatePlane(width: 300, depth: 90)
let myModel = ModelEntity(mesh: myMesh, materials: [material])
myModel.position = .init(x: 0, y: -22.48, z: 75)
queuePlayer.play()
There is one issue.
When I load the material in, it has a gray outline around it:
Everything that is the edge of transparency has a gray background, which is really odd. I've tried multiple sources and ways of exporting/making videos and I'm pretty sure it is not my video. I think it is something with RealityKit
.
How can I get rid of this?
(the yellow circle is the only content in the video, it was just a test)