Guide:Godot: Difference between revisions

From Game Making Tools Wiki
(→‎Links: Link to 'A Closer Look at the Godot Game Engine' tutorial series.)
(Added 'Video to texture' section/example)
Line 1: Line 1:
===== Links =====
== Scripts ==
=== video-to-texture.gd ===
This script renders a video to a new material on the object this script is attached to.
 
Godot only supports the [[:Wikipedia:Theora|Theora video codec]], but you can use something like [[FFmpeg]] to convert whatever video you have.
 
Source: [https://godotengine.org/qa/16661/video-skydome-video-image-texture-project-video-sphere-mesh Video skydome for VR - video to image texture? Project video on sphere mesh?]
 
<pre>
extends TestCube
 
var stream = preload("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()
</pre>
 
* Replace <code>"video.ogv"</code> with the path to your file. For me it is <code>"res://videos/test2.ogv"</code>.
* <code>TestCube</code> can be replaced with whatever object you have this attached to, I think?
 
== Tutorials ==
* [https://www.youtube.com/watch?v=K5-5j4H4Ypo GETTING STARTED IN GODOT GAME ENGINE - EASY BEGINNER TUTORIAL] - Video.
* [https://www.youtube.com/watch?v=K5-5j4H4Ypo GETTING STARTED IN GODOT GAME ENGINE - EASY BEGINNER TUTORIAL] - Video.
* [http://www.gamefromscratch.com/post/2015/01/04/A-Closer-Look-at-the-Godot-Game-Engine.aspx A Closer Look at the Godot Game Engine] - Text, but [http://www.gamefromscratch.com/page/Godot-Game-Engine-tutorial-series.aspx video versions are availible] if you prefer.
* [http://www.gamefromscratch.com/post/2015/01/04/A-Closer-Look-at-the-Godot-Game-Engine.aspx A Closer Look at the Godot Game Engine] - Text, but [http://www.gamefromscratch.com/page/Godot-Game-Engine-tutorial-series.aspx video versions are availible] if you prefer.


===== See Also =====
== See Also ==
* [[Godot|Godot]]
* [[Godot|Godot]]

Revision as of 10:36, 28 July 2017

Scripts

video-to-texture.gd

This script renders a video to a new material on the object this script is attached to.

Godot only supports the Theora video codec, but you can use something like FFmpeg to convert whatever video you have.

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

extends TestCube

var stream = preload("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()
  • Replace "video.ogv" with the path to your file. For me it is "res://videos/test2.ogv".
  • TestCube can be replaced with whatever object you have this attached to, I think?

Tutorials

See Also