Use video as background to a 3D game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By spotlessapple

For context, I’m new to Godot and am trying to create a rhythm game. Similar to Dance Dance Revolution, I would like a video playing in the background while the user interacts with the 3D scene in front of the video (where the 3D scene has a track/notes similar to what you would see in Guitar Hero). I have tried adding a VideoPlayer to a control node, but the video always plays in front of the 3D scene instead of behind it. What I’m aiming for is to have the video continuously playing in the background behind the 3D scene. How would I go about this implementation? Thanks in advance for any help!

:bust_in_silhouette: Reply From: MintSoda

I would:
Create a Sprite3D as background.
Create a Viewport.
Put VideoPlayer in a $Viewport.
(Remember to set Viewport.size to fit the video.)
Create a ViewportTexture for $Sprite3D.texture which links to the $Viewport above.
(You need to $Viewport.flip_y to ture if the video is upside down.)

UNTESTED.

:bust_in_silhouette: Reply From: spotlessapple

So I was able to get this working by using this wonderful example (main difference being that I used a videoplayer in the Viewport). The only problem here is that performance is non-trivially slow, and my game grinds to a halt until the video stops playing. Current workaround was to scrap the video (169Mbs for those curios of the size), use a sprite to project on the background (or in the GitHub project, the ViewportQuad node), and use a shader for it that looks like a moving background.