Add framerate on visualiser

This commit is contained in:
Rodolphe Houdas 2023-03-25 22:53:52 +00:00
parent 59476fe744
commit 0c12f80c91
6 changed files with 111 additions and 10 deletions

View file

@ -3,16 +3,16 @@
name="Linux/X11"
platform="Linux/X11"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/UltraleapPluginDemo.Debug.x86_64"
export_path="build/UltraleapPluginDemo.Release.x86_64"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=1
script_encryption_key=""
[preset.0.options]
@ -25,5 +25,57 @@ texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
[preset.1]
name="Synthwave Cubes"
platform="Linux/X11"
runnable=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/SynthCubes/SynthCubes.x86_64"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=0
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=true
texture_format/etc2=true
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""

View file

@ -7,6 +7,7 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7aiux"]
shader = ExtResource("1_biwbg")
shader_parameter/default_colour = Color(0, 0, 0, 1)
shader_parameter/gammaExponent = 1.6
shader_parameter/left = ExtResource("2_uqhtk")
shader_parameter/right = ExtResource("3_kniuh")

View file

@ -1,13 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://uaaq7yd773go"]
[gd_scene load_steps=4 format=3 uid="uid://uaaq7yd773go"]
[ext_resource type="Script" path="res://scripts/HUD.gd" id="1_expu4"]
[ext_resource type="AnimationLibrary" uid="uid://svwrh3vdc31s" path="res://animations/HUD_Animations.tres" id="2_dxjft"]
[ext_resource type="Script" path="res://scripts/FPSLabel.gd" id="3_jgha6"]
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("subtitle", "subtitle_animator", "tracking_choice")]
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("subtitle", "subtitle_animator", "tracking_choice", "tracking_framerate")]
script = ExtResource("1_expu4")
subtitle = NodePath("Label")
subtitle_animator = NodePath("AnimationPlayer")
tracking_choice = NodePath("OptionButton")
tracking_framerate = NodePath("HBoxContainer/TrackingFramerate")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
root_node = NodePath("../Label")
@ -21,10 +23,10 @@ anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -300.0
offset_top = -98.0
offset_right = 300.0
offset_bottom = -25.999
offset_left = 276.0
offset_top = 550.0
offset_right = 876.0
offset_bottom = 622.001
grow_horizontal = 2
grow_vertical = 0
size_flags_horizontal = 4
@ -58,5 +60,31 @@ offset_right = -20.0
offset_bottom = 49.0
grow_horizontal = 0
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 18.0
offset_top = -32.0
offset_right = -18.0
grow_horizontal = 2
grow_vertical = 0
alignment = 2
[node name="ApplicationFramerate" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "FPS: 1"
script = ExtResource("3_jgha6")
prefix = "Application Frame Rate:"
[node name="Spacer" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="TrackingFramerate" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "FPS: 1"
[connection signal="item_selected" from="OptionButton" to="." method="button_item_selected"]
[connection signal="item_selected" from="Devices" to="." method="device_selected"]

6
demo/scripts/FPSLabel.gd Normal file
View file

@ -0,0 +1,6 @@
extends Label
@export var prefix = "FPS:"
func _process(delta):
text = prefix + " " + str(Performance.get_monitor(Performance.TIME_FPS))

View file

@ -7,17 +7,29 @@ extends CanvasLayer
@export var tracking_choice : OptionButton
@export var tracking_framerate : Label
signal tracking_mode_request(tracking_mode : UltraleapTypes.TrackingMode)
signal device_selection(serial : String)
var current_device : UltraleapDevice
var latest_update : float = 0
func _ready():
subtitle_animator.play("show_subtitle")
subtitle_animator.seek(0, true)
subtitle_animator.stop(false)
func _physics_process(delta):
if (current_device == null):
return
if Time.get_unix_time_from_system() - latest_update > 0.5:
tracking_framerate.text = "Tracking Frame Rate: " + str(ceil(current_device.get_last_frame().framerate))
latest_update = Time.get_unix_time_from_system()
func play_floating_bottom_text(text : String):
subtitle.text = text
subtitle_animator.play("show_subtitle")

View file

@ -5,6 +5,8 @@ uniform sampler2D right : hint_default_black;
uniform vec3 default_colour : source_color;
uniform float gammaExponent = 1.0;
void sky() {
ivec2 left_texture_size = textureSize(left, 0);
ivec2 right_texture_size = textureSize(right, 0);
@ -25,5 +27,5 @@ void sky() {
float text_is_valid = is_left_side * left_text_is_valid + (1.0 - is_left_side) * right_text_is_valid;
COLOR = text_is_valid * pix + (1.0 - text_is_valid) * default_colour;
COLOR = pow(text_is_valid * pix + (1.0 - text_is_valid) * default_colour, vec3(gammaExponent));
}