-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b40f670
commit 13fba1b
Showing
90 changed files
with
866 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://dsexrsb8t0vi2" | ||
path="res://.godot/imported/rumble.svg-104961f6551a931675972887ab17d2bc.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-xr-tools/editor/icons/rumble.svg" | ||
dest_files=["res://.godot/imported/rumble.svg-104961f6551a931675972887ab17d2bc.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
@tool | ||
class_name XRToolsFade | ||
extends Node3D | ||
|
||
|
||
## XR Tools Fade Script | ||
## | ||
## This script manages fading the view. | ||
|
||
|
||
# Dictionary of fade requests | ||
var _faders : Dictionary = {} | ||
|
||
# Fade update flag | ||
var _update : bool = false | ||
|
||
# Fade mesh | ||
var _mesh : MeshInstance3D | ||
|
||
# Fade shader material | ||
var _material : ShaderMaterial | ||
|
||
|
||
# Add support for is_xr_class on XRTools classes | ||
func is_xr_class(name : String) -> bool: | ||
return name == "XRToolsFade" | ||
|
||
|
||
# Called when the fade node is ready | ||
func _ready() -> void: | ||
# Add to the fade_mesh group - in the future this should be replaced with | ||
# static instances. | ||
add_to_group("fade_mesh") | ||
|
||
# Get the mesh and material | ||
_mesh = $FadeMesh | ||
_material = _mesh.get_surface_override_material(0) | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
func _process(_delta : float) -> void: | ||
# Skip if nothing to update | ||
if not _update: | ||
return | ||
|
||
# Calculate the cumulative shade color | ||
var fade := Color(1, 1, 1, 0) | ||
var show := false | ||
for whom in _faders: | ||
var color := _faders[whom] as Color | ||
fade = fade.blend(color) | ||
show = true | ||
|
||
# Set the shader and show if necessary | ||
_material.set_shader_parameter("albedo", fade) | ||
_mesh.visible = show | ||
_update = false | ||
|
||
|
||
# Set the fade level | ||
func set_fade_level(p_whom : Variant, p_color : Color) -> void: | ||
# Test if fading is needed | ||
if p_color.a > 0: | ||
# Set the fade level | ||
_faders[p_whom] = p_color | ||
_update = true | ||
elif _faders.erase(p_whom): | ||
# Fade erased | ||
_update = true | ||
|
||
|
||
## Set the fade level on the fade instance | ||
static func set_fade(p_whom : Variant, p_color : Color) -> void: | ||
# In the future this use of groups should be replaced by static instances. | ||
var tree := Engine.get_main_loop() as SceneTree | ||
for node in tree.get_nodes_in_group("fade_mesh"): | ||
var fade := node as XRToolsFade | ||
if fade: | ||
fade.set_fade_level(p_whom, p_color) |
8 changes: 4 additions & 4 deletions
8
addons/godot-xr-tools/staging/fade.gdshader → addons/godot-xr-tools/effects/fade.gdshader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
shader_type spatial; | ||
render_mode depth_test_disabled, skip_vertex_transform, unshaded, cull_disabled; | ||
|
||
uniform float alpha = 0.0; | ||
uniform vec4 albedo : source_color; | ||
|
||
void vertex() { | ||
POSITION = vec4(VERTEX.x, -VERTEX.y, 0.0, 1.0); | ||
} | ||
|
||
void fragment() { | ||
ALBEDO = vec3(0.0, 0.0, 0.0); | ||
ALPHA = alpha; | ||
} | ||
ALBEDO = albedo.rgb; | ||
ALPHA = albedo.a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[gd_scene load_steps=5 format=3 uid="uid://wtpox7m5vu2b"] | ||
|
||
[ext_resource type="Script" path="res://addons/godot-xr-tools/effects/fade.gd" id="1_6667f"] | ||
[ext_resource type="Shader" path="res://addons/godot-xr-tools/effects/fade.gdshader" id="1_tjen8"] | ||
|
||
[sub_resource type="QuadMesh" id="QuadMesh_aqp6r"] | ||
custom_aabb = AABB(-5000, -5000, -5000, 10000, 10000, 10000) | ||
size = Vector2(2, 2) | ||
|
||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xjgy8"] | ||
render_priority = 50 | ||
shader = ExtResource("1_tjen8") | ||
shader_parameter/albedo = Color(0, 0, 0, 1) | ||
|
||
[node name="Fade" type="Node3D"] | ||
script = ExtResource("1_6667f") | ||
|
||
[node name="FadeMesh" type="MeshInstance3D" parent="."] | ||
visible = false | ||
mesh = SubResource("QuadMesh_aqp6r") | ||
surface_material_override/0 = SubResource("ShaderMaterial_xjgy8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.