Skip to content

Commit

Permalink
Move our staging logic into the plugin so it becomes reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanOlij committed Oct 27, 2022
1 parent c32013c commit c754ebc
Show file tree
Hide file tree
Showing 33 changed files with 531 additions and 252 deletions.
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Enhanced pointer laser visibility options for colliding with targets.
- Implement poke feature (finger interaction)
- Improvements to snap turning
- Moved staging solution into plugin so it can be re-used

# 3.0.0
- Included demo project with test scenes to evaluate features
Expand Down
Binary file not shown.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

importer="texture"
type="StreamTexture"
path.s3tc="res://.import/Hold trigger to continue.png-04f8ef34242dded79e63d1b30316b5cc.s3tc.stex"
path.etc="res://.import/Hold trigger to continue.png-04f8ef34242dded79e63d1b30316b5cc.etc.stex"
path.s3tc="res://.import/Hold trigger to continue.png-ce0a3a4de13c262f7015326bad2cb09d.s3tc.stex"
path.etc="res://.import/Hold trigger to continue.png-ce0a3a4de13c262f7015326bad2cb09d.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}

[deps]

source_file="res://assets/misc/Hold trigger to continue.png"
dest_files=[ "res://.import/Hold trigger to continue.png-04f8ef34242dded79e63d1b30316b5cc.s3tc.stex", "res://.import/Hold trigger to continue.png-04f8ef34242dded79e63d1b30316b5cc.etc.stex" ]
source_file="res://addons/godot-xr-tools/assets/misc/Hold trigger to continue.png"
dest_files=[ "res://.import/Hold trigger to continue.png-ce0a3a4de13c262f7015326bad2cb09d.s3tc.stex", "res://.import/Hold trigger to continue.png-ce0a3a4de13c262f7015326bad2cb09d.etc.stex" ]

[params]

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

importer="texture"
type="StreamTexture"
path.s3tc="res://.import/progress_bar.png-e635a708d4c3d6f7e2c7a059ddb765fc.s3tc.stex"
path.etc="res://.import/progress_bar.png-e635a708d4c3d6f7e2c7a059ddb765fc.etc.stex"
path.s3tc="res://.import/progress_bar.png-2ef3cbffca173889900be004fdeb1700.s3tc.stex"
path.etc="res://.import/progress_bar.png-2ef3cbffca173889900be004fdeb1700.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}

[deps]

source_file="res://assets/misc/progress_bar.png"
dest_files=[ "res://.import/progress_bar.png-e635a708d4c3d6f7e2c7a059ddb765fc.s3tc.stex", "res://.import/progress_bar.png-e635a708d4c3d6f7e2c7a059ddb765fc.etc.stex" ]
source_file="res://addons/godot-xr-tools/assets/misc/progress_bar.png"
dest_files=[ "res://.import/progress_bar.png-2ef3cbffca173889900be004fdeb1700.s3tc.stex", "res://.import/progress_bar.png-2ef3cbffca173889900be004fdeb1700.etc.stex" ]

[params]

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions addons/godot-xr-tools/misc/arvr_helpers.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ static func get_arvr_origin(node: Node, path: NodePath = NodePath("")) -> ARVROr
return origin
current = current.get_parent()

# We check our children but only one level
for child in node.get_children():
origin = child as ARVROrigin
if origin:
return origin

# Could not find origin
return null

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ signal continue_pressed
# If enabled, rotate our screen to follow the camera

export (bool) var follow_camera = true setget set_follow_camera
export (NodePath) var camera
export (Curve) var follow_speed

var camera_node : ARVRCamera
var camera : ARVRCamera

func set_follow_camera(p_enabled):
follow_camera = p_enabled
_update_follow_camera()

func set_camera(p_camera : ARVRCamera):
camera = p_camera
_update_follow_camera()

func _update_follow_camera():
if camera_node and !Engine.is_editor_hint():
if camera and !Engine.is_editor_hint():
set_process(follow_camera)

## Splash screen
Expand Down Expand Up @@ -103,14 +106,16 @@ func _ready():

_update_enable_press_to_continue()

camera_node = get_node_or_null(camera)
_update_follow_camera()

func _process(delta):
if Engine.is_editor_hint():
return

var camera_dir = camera_node.global_transform.basis.z
if !camera:
return

var camera_dir = camera.global_transform.basis.z
camera_dir.y = 0.0
camera_dir = camera_dir.normalized()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=13 format=2]

[ext_resource path="res://assets/godot/splash.png" type="Texture" id=1]
[ext_resource path="res://loading_screen/loading_screen.gd" type="Script" id=2]
[ext_resource path="res://loading_screen/loading_screen_shader.tres" type="Shader" id=3]
[ext_resource path="res://assets/misc/progress_bar.png" type="Texture" id=4]
[ext_resource path="res://assets/misc/Hold trigger to continue.png" type="Texture" id=5]
[ext_resource path="res://addons/godot-xr-tools/staging/loading_screen.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/staging/loading_screen_shader.tres" type="Shader" id=3]
[ext_resource path="res://addons/godot-xr-tools/assets/misc/progress_bar.png" type="Texture" id=4]
[ext_resource path="res://addons/godot-xr-tools/assets/misc/Hold trigger to continue.png" type="Texture" id=5]
[ext_resource path="res://addons/godot-xr-tools/misc/hold_button.tscn" type="PackedScene" id=6]

[sub_resource type="Curve" id=21]
Expand All @@ -17,7 +16,6 @@ size = Vector2( 80, 60 )
[sub_resource type="SpatialMaterial" id=1]
flags_transparent = true
flags_unshaded = true
albedo_texture = ExtResource( 1 )

[sub_resource type="ShaderMaterial" id=18]
shader = ExtResource( 3 )
Expand All @@ -41,7 +39,6 @@ albedo_texture = ExtResource( 5 )
[node name="LoadingScreen" type="Spatial"]
script = ExtResource( 2 )
follow_speed = SubResource( 21 )
splash_screen = ExtResource( 1 )

[node name="SplashScreen" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 15, -50 )
Expand All @@ -51,7 +48,6 @@ material/0 = SubResource( 1 )
[node name="ProgressBar" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -10 )
mesh = SubResource( 3 )
material/0 = null

[node name="PressToContinue" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, -10 )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
[gd_resource type="VisualShader" load_steps=15 format=2]

[sub_resource type="VisualShaderNodeCompare" id=5]
output_port_for_preview = 0
default_input_values = [ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, 1e-05 ]
type = 1
function = 4
condition = 1

[sub_resource type="VisualShaderNodeScalarUniform" id=6]
uniform_name = "progress"

[sub_resource type="VisualShaderNodeVectorCompose" id=7]

[sub_resource type="VisualShaderNodeScalarOp" id=8]
output_port_for_preview = 0
operator = 6

[sub_resource type="VisualShaderNodeColorUniform" id=9]
uniform_name = "bar_color"

[sub_resource type="VisualShaderNodeTextureUniform" id=17]
uniform_name = "bar_texture"
texture_type = 1

[sub_resource type="VisualShaderNodeVectorOp" id=18]
operator = 2

[sub_resource type="VisualShaderNodeScalarOp" id=19]
operator = 2

[sub_resource type="VisualShaderNodeVec3Uniform" id=20]
uniform_name = "cutout"

[sub_resource type="VisualShaderNodeInput" id=10]
input_name = "uv"

[sub_resource type="VisualShaderNodeVectorOp" id=11]
default_input_values = [ 0, Vector3( 0, 0, 0 ), 1, Vector3( 10, 1, 0 ) ]
operator = 2

[sub_resource type="VisualShaderNodeVectorOp" id=12]
default_input_values = [ 0, Vector3( 0, 0, 0 ), 1, Vector3( 5, 0.5, 0 ) ]
operator = 1

[sub_resource type="VisualShaderNodeVectorFunc" id=13]
function = 6

[sub_resource type="VisualShaderNodeCompare" id=15]
output_port_for_preview = 0
default_input_values = [ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, 1e-05 ]
type = 1
function = 2
condition = 1

[resource]
code = "shader_type spatial;
render_mode specular_schlick_ggx, async_visible, unshaded;

uniform vec4 bar_color : hint_color;
uniform sampler2D bar_texture : hint_albedo;
uniform vec3 cutout;
uniform float progress;



void vertex() {
// Output:0

}

void fragment() {
// ColorUniform:15
vec3 n_out15p0 = bar_color.rgb;
float n_out15p1 = bar_color.a;

// TextureUniform:16
vec3 n_out16p0;
float n_out16p1;
{
vec4 n_tex_read = texture(bar_texture, UV.xy);
n_out16p0 = n_tex_read.rgb;
n_out16p1 = n_tex_read.a;
}

// VectorOp:17
vec3 n_out17p0 = n_out15p0 * n_out16p0;

// Input:3
vec3 n_out3p0 = vec3(UV, 0.0);

// VectorOp:4
vec3 n_in4p1 = vec3(10.00000, 1.00000, 0.00000);
vec3 n_out4p0 = n_out3p0 * n_in4p1;

// VectorOp:5
vec3 n_in5p1 = vec3(5.00000, 0.50000, 0.00000);
vec3 n_out5p0 = n_out4p0 - n_in5p1;

// VectorFunc:6
vec3 n_out6p0 = abs(n_out5p0);

// VectorUniform:19
vec3 n_out19p0 = cutout;

// Compare:8
bool n_out8p0;
{
bvec3 _bv = greaterThan(n_out6p0, n_out19p0);
n_out8p0 = any(_bv);
}

// ScalarUniform:12
float n_out12p0 = progress;

// VectorCompose:13
float n_in13p1 = 0.00000;
float n_in13p2 = 0.00000;
vec3 n_out13p0 = vec3(n_out12p0, n_in13p1, n_in13p2);

// Compare:11
bool n_out11p0;
{
bvec3 _bv = lessThan(n_out3p0, n_out13p0);
n_out11p0 = any(_bv);
}

// ScalarOp:14
float n_out14p0 = max((n_out8p0 ? 1.0 : 0.0), (n_out11p0 ? 1.0 : 0.0));

// ScalarOp:18
float n_out18p0 = n_out16p1 * n_out14p0;

// Output:0
ALBEDO = n_out17p0;
ALPHA = n_out18p0;

}

void light() {
// Output:0

}
"
graph_offset = Vector2( -195.354, 305.623 )
flags/unshaded = true
nodes/fragment/0/position = Vector2( 1220, 440 )
nodes/fragment/3/node = SubResource( 10 )
nodes/fragment/3/position = Vector2( -320, 580 )
nodes/fragment/4/node = SubResource( 11 )
nodes/fragment/4/position = Vector2( -120, 460 )
nodes/fragment/5/node = SubResource( 12 )
nodes/fragment/5/position = Vector2( 60, 460 )
nodes/fragment/6/node = SubResource( 13 )
nodes/fragment/6/position = Vector2( 260, 480 )
nodes/fragment/8/node = SubResource( 15 )
nodes/fragment/8/position = Vector2( 500, 480 )
nodes/fragment/11/node = SubResource( 5 )
nodes/fragment/11/position = Vector2( 500, 780 )
nodes/fragment/12/node = SubResource( 6 )
nodes/fragment/12/position = Vector2( -40, 820 )
nodes/fragment/13/node = SubResource( 7 )
nodes/fragment/13/position = Vector2( 280, 940 )
nodes/fragment/14/node = SubResource( 8 )
nodes/fragment/14/position = Vector2( 743.56, 671.244 )
nodes/fragment/15/node = SubResource( 9 )
nodes/fragment/15/position = Vector2( 640, 260 )
nodes/fragment/16/node = SubResource( 17 )
nodes/fragment/16/position = Vector2( 720, 440 )
nodes/fragment/17/node = SubResource( 18 )
nodes/fragment/17/position = Vector2( 980, 340 )
nodes/fragment/18/node = SubResource( 19 )
nodes/fragment/18/position = Vector2( 980, 560 )
nodes/fragment/19/node = SubResource( 20 )
nodes/fragment/19/position = Vector2( 160, 620 )
nodes/fragment/connections = PoolIntArray( 3, 0, 4, 0, 4, 0, 5, 0, 5, 0, 6, 0, 6, 0, 8, 0, 3, 0, 11, 0, 13, 0, 11, 1, 12, 0, 13, 0, 8, 0, 14, 0, 11, 0, 14, 1, 15, 0, 17, 0, 16, 0, 17, 1, 17, 0, 0, 0, 16, 1, 18, 0, 18, 0, 0, 1, 14, 0, 18, 1, 3, 0, 4, 0, 4, 0, 5, 0, 5, 0, 6, 0, 6, 0, 8, 0, 3, 0, 11, 0, 13, 0, 11, 1, 12, 0, 13, 0, 8, 0, 14, 0, 11, 0, 14, 1, 15, 0, 17, 0, 16, 0, 17, 1, 17, 0, 0, 0, 16, 1, 18, 0, 18, 0, 0, 1, 14, 0, 18, 1, 19, 0, 8, 1 )
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class_name XRToolsSceneBase
extends Spatial

## Introduction
Expand All @@ -6,8 +7,6 @@ extends Spatial
# It ensures that we have all bits in place to load
# our scene into our staging scene.

class_name SceneBase

# Emit this signal to let staging know we should return to our menu scene
signal exit_to_main_menu

Expand Down Expand Up @@ -56,7 +55,15 @@ func scene_loaded():
# physically halfway across the room.
center_player_on($ARVROrigin.global_transform)

func scene_visible():
# Called after the scene becomes fully visible
pass

func scene_pre_exiting():
# Called before we start fading out and removing our scene
pass

func scene_exiting():
# called when we're about to remove this scene
# called right before we remove this scene
pass

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://scenes/scene_base.gd" type="Script" id=1]
[ext_resource path="res://addons/godot-xr-tools/staging/scene_base.gd" type="Script" id=1]
[ext_resource path="res://default_env.tres" type="Environment" id=2]

[node name="SceneBase" type="Spatial"]
Expand Down
Loading

0 comments on commit c754ebc

Please sign in to comment.