NDI Working

This commit is contained in:
2025-07-22 09:00:28 +10:00
parent fc6fa30c85
commit 853e4423f7
41 changed files with 1375 additions and 3 deletions

View File

@@ -0,0 +1,73 @@
[gd_scene load_steps=4 format=3 uid="uid://deioml0m7ep1t"]
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_4r73q"]
emission_shape = 1
emission_sphere_radius = 1.0
direction = Vector3(0, 1, 0)
initial_velocity_min = 2.0
initial_velocity_max = 6.0
[sub_resource type="SphereMesh" id="SphereMesh_jpqj6"]
[sub_resource type="LabelSettings" id="LabelSettings_ln6fu"]
font_size = 24
shadow_size = 5
shadow_color = Color(0, 0, 0, 0.235294)
[node name="3DOutput" type="SubViewportContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="Node3D" type="Node3D" parent="."]
[node name="GPUParticles3D" type="GPUParticles3D" parent="Node3D"]
amount = 32
lifetime = 2.0
process_material = SubResource("ParticleProcessMaterial_4r73q")
draw_pass_1 = SubResource("SphereMesh_jpqj6")
[node name="SubViewportB" type="SubViewport" parent="."]
handle_input_locally = false
size = Vector2i(1152, 648)
render_target_update_mode = 4
[node name="NDIOutput" type="NDIOutput" parent="SubViewportB"]
name = "Godot Cam B"
enable_editor_output = true
[node name="Camera3D" type="Camera3D" parent="SubViewportB"]
transform = Transform3D(1, 0, 0, 0, -0.0010647, 0.999999, 0, -0.999999, -0.0010647, 0, 6.41845, 0)
current = true
[node name="SubViewportA" type="SubViewport" parent="."]
handle_input_locally = false
size = Vector2i(1152, 648)
render_target_update_mode = 4
[node name="NDIOutput" type="NDIOutput" parent="SubViewportA"]
name = "Godot Cam A"
enable_editor_output = true
[node name="Label" type="Label" parent="SubViewportA"]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 31.0
offset_top = -357.0
offset_right = 534.0
offset_bottom = -27.0
grow_vertical = 0
text = "NDIOutput always transmits the Viewport closest up the Tree. When running in the Editor that's the 2D View.
If you want to display a camera view, add NDIOutput to a SubViewport instead. You can skip the SubViewportContainer incase you don't need the Scene to be visible when running the Game. "
label_settings = SubResource("LabelSettings_ln6fu")
horizontal_alignment = 3
autowrap_mode = 2
[node name="Camera3D" type="Camera3D" parent="SubViewportA"]
transform = Transform3D(0.99299, -0.0520139, 0.106136, 0, 0.897966, 0.440065, -0.118196, -0.43698, 0.891672, -2.28829, 1.75016, 5.03714)
current = true

View File

@@ -0,0 +1,58 @@
[gd_scene load_steps=5 format=3 uid="uid://p6ywmqtt7nke"]
[ext_resource type="Texture2D" uid="uid://cfvxj5cdj3n45" path="res://addons/godot-ndi/demo/assets/icon.svg" id="1_ekn6m"]
[sub_resource type="Animation" id="Animation_62e2m"]
length = 0.001
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1034, 527)]
}
[sub_resource type="Animation" id="Animation_0fbet"]
resource_name = "new_animation"
length = 8.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 3.9627, 7.9587),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(116, 119), Vector2(1034, 527), Vector2(116, 119)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ee4bf"]
_data = {
&"RESET": SubResource("Animation_62e2m"),
&"new_animation": SubResource("Animation_0fbet")
}
[node name="SubViewport" type="Node2D"]
[node name="NDIOutput" type="NDIOutput" parent="."]
name = "Godot (Animation)"
[node name="Icon" type="Sprite2D" parent="."]
position = Vector2(1034, 527)
scale = Vector2(1.463, 1.463)
texture = ExtResource("1_ekn6m")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_ee4bf")
}
autoplay = "new_animation"

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=2 format=3 uid="uid://dydvtidqppffs"]
[ext_resource type="Script" uid="uid://kbgdevvugj7k" path="res://addons/godot-ndi/demo/ndi_finder.gd" id="1_0rvup"]
[node name="Canvas" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
autoplay = true
expand = true
[node name="NDIFinder" type="NDIFinder" parent="."]
script = ExtResource("1_0rvup")
[connection signal="sources_changed" from="NDIFinder" to="NDIFinder" method="_on_sources_changed"]
[connection signal="sources_found" from="NDIFinder" to="NDIFinder" method="_on_sources_found"]
[connection signal="sources_gone" from="NDIFinder" to="NDIFinder" method="_on_sources_gone"]

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=3 uid="uid://byblss3lhwvqm"]
[sub_resource type="VideoStreamNDI" id="VideoStreamNDI_lv7vm"]
[node name="Canvas" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stream = SubResource("VideoStreamNDI_lv7vm")
autoplay = true
expand = true

View File

@@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=3 uid="uid://ddr3hiaft61tl"]
[ext_resource type="VideoStream" uid="uid://0whnog13yrlf" path="res://addons/godot-ndi/demo/assets/liftoff_space_shuttle_atlantis.ogv" id="1_utmvk"]
[ext_resource type="AudioStream" uid="uid://dyvxmok1n3vu1" path="res://addons/godot-ndi/demo/assets/sub-d-more-jazz-guitar.wav" id="2_51pmd"]
[ext_resource type="Script" uid="uid://d2sex4jisnkck" path="res://addons/godot-ndi/demo/video_stream_player.gd" id="2_w6vuq"]
[ext_resource type="VideoStream" path="res://addons/godot-ndi/demo/assets/twitch_sync_footage.ogv" id="3_ug8g3"]
[node name="Canvas" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
volume_db = -15.0
autoplay = true
script = ExtResource("2_w6vuq")
playlist = Array[VideoStream]([ExtResource("1_utmvk"), ExtResource("3_ug8g3")])
[node name="AudioStreamPlayer" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("2_51pmd")
autoplay = true
panning_strength = 0.0
[node name="NDIOutput" type="NDIOutput" parent="."]
name = "Godot (Video)"
audio_bus = &"Master"
[connection signal="finished" from="VideoStreamPlayer" to="VideoStreamPlayer" method="_on_finished"]

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cfvxj5cdj3n45"
path="res://.godot/imported/icon.svg-5dbb75b05306facc4cf78b15baaae64d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/godot-ndi/demo/assets/icon.svg"
dest_files=["res://.godot/imported/icon.svg-5dbb75b05306facc4cf78b15baaae64d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1 @@
uid://0whnog13yrlf

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dyvxmok1n3vu1"
path="res://.godot/imported/sub-d-more-jazz-guitar.wav-6bba7f91e7070b729764277f88bb96b0.sample"
[deps]
source_file="res://addons/godot-ndi/demo/assets/sub-d-more-jazz-guitar.wav"
dest_files=["res://.godot/imported/sub-d-more-jazz-guitar.wav-6bba7f91e7070b729764277f88bb96b0.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=true
edit/loop_mode=2
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@@ -0,0 +1 @@
uid://4mp8kyfc212k

View File

@@ -0,0 +1,13 @@
extends NDIFinder
@onready var player: VideoStreamPlayer = $"../VideoStreamPlayer"
func _on_sources_changed() -> void:
player.stream = get_sources().pop_front()
player.play()
func _on_sources_found(found_sources: Array[VideoStreamNDI]) -> void:
print("NDI sources found: ", found_sources.map(func (source: VideoStreamNDI): return source.get_name()))
func _on_sources_gone(gone_sources: Array[VideoStreamNDI]) -> void:
print("NDI sources gone: ", gone_sources.map(func (source: VideoStreamNDI): return source.get_name()))

View File

@@ -0,0 +1 @@
uid://kbgdevvugj7k

View File

@@ -0,0 +1,17 @@
extends VideoStreamPlayer
@export var playlist: Array[VideoStream] = []
func _ready() -> void:
_on_finished()
func _on_finished() -> void:
if playlist.is_empty():
return
var next_idx = playlist.find(stream) + 1
if next_idx >= playlist.size():
next_idx = 0
stream = playlist[next_idx]
play()

View File

@@ -0,0 +1 @@
uid://d2sex4jisnkck