I am trying to play a video in SceneKit
. I can hear the audio but video is not rendering. The way i am using the scene is as follows. Please help.
SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/plane.scn"];
SCNNode *plane = [scene.rootNode childNodeWithName:@"plane" recursively:YES];
AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:@"https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_5mb.mp4"]];
plane.geometry.firstMaterial.diffuse.contents = player;
[player play];
SCNView *scnView = (SCNView *)self.view;
scnView.scene = scene;
scnView.allowsCameraControl = YES;
scnView.showsStatistics = YES;
scnView.backgroundColor = [UIColor blackColor];
You need to use a real iPhone not simulator to enjoy.
Another reason is the shading in the material panel should not be physical based. You may try Blinn. The code has no problem.
If using a physical based, you have to add an extra light to make it work.
you can keep PBR and get glass reflections with a non-rough material. use the emission
instead of diffuse
for the the video though
plane.geometry.firstMaterial.emission.contents = player
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.