Video skydome for VR - video to image texture? Project video on sphere mesh?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By blurymind
:warning: Old Version Published before Godot 3 was released.

Is it possible in godot to play a video file (ogg) ontop of a 3d mesh - use the video as the texture?
I can see there is a videoplayer class, but it doesnt seem to have that or at least I see no examples of it anywhere.

Appgamekit has a function to play a video to an image:
https://www.appgamekit.com/documentation/Reference/Video/PlayVideoToImage.htm

Unity has many ways to do it too -

Can godot do that too? Also How?

Here are some 360 video files to play with

:bust_in_silhouette: Reply From: mollusca

You can use VideoPlayer.get_video_texture() to get a video texture, and then simply assign the texture to the material of your mesh and it should work. Here’s a basic example using a TestCube:

extends TestCube

var stream = preload("my_video.ogv")

func _ready():
    var player = VideoPlayer.new()
    player.set_stream(stream)
    add_child(player)
    var texture = player.get_video_texture()
    var material = FixedMaterial.new()
    material.set_texture(FixedMaterial.PARAM_DIFFUSE, texture)
    material.set_flag(Material.FLAG_UNSHADED, true)
    set_material_override(material)
    player.play()

Hi, would it be possible to update this for godot 3? I think FixedMaterial is now SpatialMaterial and I can’t find PARAM_DIFFUSE anywhere.

dodgyville | 2017-11-14 10:09

Here you go:

(I just do not know how to loop it or how to fit it to mesh :frowning: )

    extends MeshInstance

# class member variables go here, for example:
# var a = 2
# var b = "textvar"

var stream = preload("res://tex/video.ogv")

func _ready():
    var player = VideoPlayer.new()
    player.set_stream(stream)
	
    add_child(player)
	
    var texture = player.get_video_texture()
	
    var material = SpatialMaterial.new()
    material.albedo_texture = texture
    material.set_flag(material.FLAG_UNSHADED, true)
    set_material_override(material)
	
	
    player.play()

kosek | 2018-02-12 12:42