Topic was automatically imported from the old Question2Answer platform.
Asked By
blurymind
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.
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 )
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()