Skip to content

Commit

Permalink
Adding a scene that prevents the hickup the user experiences the firs…
Browse files Browse the repository at this point in the history
…t time he/she uses certain functions
  • Loading branch information
BastiaanOlij committed Mar 10, 2019
1 parent 8e1c96d commit 32e7ba3
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 138 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -3,6 +3,14 @@ This repository contains a number of support files and support scenes that can b

## How to Use

### Preventing hickups

As many of the functions in this module will hide objects that are later shown as the user performs actions, the user will experience a hickup as Godot compiles the shader used to draw the object on screen.

To combat this you will find a scene in this module called `misc/VR_Common_Shader_Cache.tscn`.
Add this scene as a child node to your ARVRCamera. This will trigger the required shaders being
compiled the first time your main scene loads.

### Teleportation
- if your scene doesn't have a floor yet:
- add a `StaticBody` node to the scene root
Expand Down
37 changes: 4 additions & 33 deletions addons/vr-common/functions/Function_Direct_movement.tscn
Expand Up @@ -3,51 +3,22 @@
[ext_resource path="res://addons/vr-common/functions/Function_Direct_movement.gd" type="Script" id=1]

[sub_resource type="CapsuleShape" id=1]

radius = 0.3
height = 1.2

[node name="Function_Direct_movement" type="Spatial" index="0"]

[node name="Function_Direct_movement" type="Spatial"]
script = ExtResource( 1 )
origin = null
camera = null
player_height = 1.8
player_radius = 0.4
turn_delay = 0.2
turn_angle = 20.0
max_speed = 500.0
drag_factor = 0.1

[node name="KinematicBody" type="KinematicBody" parent="." index="0"]

input_ray_pickable = true
input_capture_on_drag = false
[node name="KinematicBody" type="KinematicBody" parent="."]
collision_layer = 524288
collision_mask = 1
axis_lock_linear_x = false
axis_lock_linear_y = false
axis_lock_linear_z = false
axis_lock_angular_x = false
axis_lock_angular_y = false
axis_lock_angular_z = false
collision/safe_margin = 0.001
_sections_unfolded = [ "Collision", "Transform" ]

[node name="CollisionShape" type="CollisionShape" parent="KinematicBody" index="0"]

[node name="CollisionShape" type="CollisionShape" parent="KinematicBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.9, 0 )
shape = SubResource( 1 )
disabled = false
_sections_unfolded = [ "Transform" ]

[node name="Tail" type="RayCast" parent="KinematicBody" index="1"]

[node name="Tail" type="RayCast" parent="KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 )
enabled = true
exclude_parent = true
cast_to = Vector3( 0, -0.6, 0 )
collision_mask = 1
_sections_unfolded = [ "Transform" ]


27 changes: 5 additions & 22 deletions addons/vr-common/functions/Function_Teleport.tscn
@@ -1,38 +1,21 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://addons/vr-common/functions/Function_Teleport.gd" type="Script" id=1]
[ext_resource path="res://addons/vr-common/materials/teleport.tres" type="Material" id=2]
[ext_resource path="res://addons/vr-common/images/teleport_target.png" type="Texture" id=3]
[ext_resource path="res://addons/vr-common/materials/target.tres" type="Material" id=3]
[ext_resource path="res://addons/vr-common/materials/capule.tres" type="Material" id=4]

[sub_resource type="PlaneMesh" id=1]

size = Vector2( 0.05, 1 )
subdivide_depth = 40

[sub_resource type="PlaneMesh" id=2]

size = Vector2( 1, 1 )

[sub_resource type="SpatialMaterial" id=3]

flags_transparent = true
flags_unshaded = true
params_diffuse_mode = 1
params_cull_mode = 2
albedo_color = Color( 0.176471, 0.313726, 0.862745, 1 )
albedo_texture = ExtResource( 3 )

[sub_resource type="CapsuleMesh" id=4]

radius = 0.3
mid_height = 1.2

[sub_resource type="SpatialMaterial" id=5]

flags_transparent = true
albedo_color = Color( 0.0337219, 0.241112, 0.863281, 0.497255 )
roughness = 0.0

[node name="Function_Teleport" type="KinematicBody"]
input_ray_pickable = false
collision/safe_margin = 0.01
Expand All @@ -45,12 +28,12 @@ material/0 = ExtResource( 2 )

[node name="Target" type="MeshInstance" parent="."]
mesh = SubResource( 2 )
material/0 = SubResource( 3 )
material/0 = ExtResource( 3 )

[node name="Player_figure" type="Position3D" parent="Target"]

[node name="Capsule" type="MeshInstance" parent="Target/Player_figure"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.9, 0 )
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
material/0 = ExtResource( 4 )

89 changes: 7 additions & 82 deletions addons/vr-common/functions/Function_pointer.tscn
@@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=2]

[sub_resource type="GDScript" id=1]
[ext_resource path="res://addons/vr-common/materials/pointer.tres" type="Material" id=1]

[sub_resource type="GDScript" id=1]
script/source = "\"res://addons/vr-common/functions/Function_pointer.tscn\"extends Spatial

var target = null
Expand Down Expand Up @@ -64,99 +65,23 @@ func _process(delta):

"
[sub_resource type="SpatialMaterial" id=2]
render_priority = 0
flags_transparent = false
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 1
params_specular_mode = 0
params_blend_mode = 0
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 1, 0.15625, 0.15625, 0.740314 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 1, 0.171875, 0.171875, 1 )
emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Emission", "Flags", "Metallic", "Vertex Color" ]
[sub_resource type="CubeMesh" id=3]
material = SubResource( 2 )
[sub_resource type="CubeMesh" id=2]
material = ExtResource( 1 )
size = Vector3( 0.002, 0.002, 10 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 20
[node name="Function_pointer" type="Spatial"]
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0 )
script = SubResource( 1 )
_sections_unfolded = [ "Transform" ]
[node name="Laser" type="MeshInstance" parent="." index="0"]
[node name="Laser" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, -5 )
layers = 1
material_override = null
cast_shadow = 0
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
skeleton = NodePath("..")
mesh = SubResource( 2 )
material/0 = null
_sections_unfolded = [ "Geometry", "Transform" ]
[node name="RayCast" type="RayCast" parent="Laser" index="0"]
[node name="RayCast" type="RayCast" parent="Laser"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5 )
enabled = true
exclude_parent = true
cast_to = Vector3( 0, 0, -10 )
collision_mask = 1
34 changes: 34 additions & 0 deletions addons/vr-common/images/icon.png.import
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-fb3b2ecb55ac1327d82f6710eba4f8b4.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/vr-common/images/icon.png"
dest_files=[ "res://.import/icon.png-fb3b2ecb55ac1327d82f6710eba4f8b4.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
4 changes: 4 additions & 0 deletions addons/vr-common/images/teleport_arrow.png.import
Expand Up @@ -4,6 +4,10 @@ importer="texture"
type="StreamTexture"
path.s3tc="res://.import/teleport_arrow.png-9ee8732a3d27e6e53f97efad743b9f9b.s3tc.stex"
path.etc2="res://.import/teleport_arrow.png-9ee8732a3d27e6e53f97efad743b9f9b.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}

[deps]

Expand Down
4 changes: 4 additions & 0 deletions addons/vr-common/images/teleport_target.png.import
Expand Up @@ -4,6 +4,10 @@ importer="texture"
type="StreamTexture"
path.s3tc="res://.import/teleport_target.png-779f853f62e0e2207f5821dfbc8b780c.s3tc.stex"
path.etc2="res://.import/teleport_target.png-779f853f62e0e2207f5821dfbc8b780c.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}

[deps]

Expand Down
7 changes: 7 additions & 0 deletions addons/vr-common/materials/capule.tres
@@ -0,0 +1,7 @@
[gd_resource type="SpatialMaterial" format=2]

[resource]
flags_transparent = true
albedo_color = Color( 0.0337219, 0.241112, 0.863281, 0.497255 )
roughness = 0.0

7 changes: 7 additions & 0 deletions addons/vr-common/materials/pointer.tres
@@ -0,0 +1,7 @@
[gd_resource type="SpatialMaterial" format=2]

[resource]
flags_unshaded = true
params_diffuse_mode = 1
albedo_color = Color( 1, 0.15625, 0.15625, 0.740314 )

12 changes: 12 additions & 0 deletions addons/vr-common/materials/target.tres
@@ -0,0 +1,12 @@
[gd_resource type="SpatialMaterial" load_steps=2 format=2]

[ext_resource path="res://addons/vr-common/images/teleport_target.png" type="Texture" id=1]

[resource]
flags_transparent = true
flags_unshaded = true
params_diffuse_mode = 1
params_cull_mode = 2
albedo_color = Color( 0.176471, 0.313726, 0.862745, 1 )
albedo_texture = ExtResource( 1 )

1 change: 0 additions & 1 deletion addons/vr-common/materials/teleport.tres
Expand Up @@ -4,7 +4,6 @@
[ext_resource path="res://addons/vr-common/images/teleport_arrow.png" type="Texture" id=2]

[resource]

shader = ExtResource( 1 )
shader_param/scale_t = 0.2
shader_param/length = 30.0
Expand Down
10 changes: 10 additions & 0 deletions addons/vr-common/misc/VR_Common_Shader_Cache.gd
@@ -0,0 +1,10 @@
extends Spatial

var countdown = 2

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
countdown = countdown - 1
if countdown == 0:
visible = false
set_process(false)
34 changes: 34 additions & 0 deletions addons/vr-common/misc/VR_Common_Shader_Cache.tscn
@@ -0,0 +1,34 @@
[gd_scene load_steps=7 format=2]

[ext_resource path="res://addons/vr-common/misc/VR_Common_Shader_Cache.gd" type="Script" id=1]
[ext_resource path="res://addons/vr-common/materials/teleport.tres" type="Material" id=2]
[ext_resource path="res://addons/vr-common/materials/target.tres" type="Material" id=3]
[ext_resource path="res://addons/vr-common/materials/capule.tres" type="Material" id=4]
[ext_resource path="res://addons/vr-common/materials/pointer.tres" type="Material" id=5]

[sub_resource type="PlaneMesh" id=2]
size = Vector2( 0.001, 0.001 )

[node name="vr_common_shader_cache" type="Spatial"]
script = ExtResource( 1 )

[node name="teleport" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 2 )
material/0 = ExtResource( 2 )

[node name="target" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 2 )
material/0 = ExtResource( 3 )

[node name="capsule" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 2 )
material/0 = ExtResource( 4 )

[node name="pointer" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 2 )
material/0 = ExtResource( 5 )

0 comments on commit 32e7ba3

Please sign in to comment.