test out border shader
This commit is contained in:
parent
8d1a380977
commit
4fe0f1e4c9
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=3 uid="uid://eecv28y6jxk4"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://eecv28y6jxk4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://clc5dre31iskm" path="res://addons/godot-xr-tools/xr/start_xr.tscn" id="1_i4c04"]
|
||||
[ext_resource type="Script" path="res://content/main.gd" id="1_uvrd4"]
|
||||
|
@ -12,6 +12,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://lrehk38exd5n" path="res://content/system/keyboard/keyboard.tscn" id="9_e5n3p"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbemihbxkd4ll" path="res://content/system/house/house.tscn" id="9_np6mw"]
|
||||
[ext_resource type="PackedScene" uid="uid://bhyddd1f0ry1x" path="res://content/ui/onboarding/onboarding.tscn" id="12_uq2nj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dclceqjqfxekx" path="res://content/ui/test.tscn" id="13_eg13b"]
|
||||
|
||||
[sub_resource type="Sky" id="Sky_vhymk"]
|
||||
sky_material = ExtResource("5_wgwf8")
|
||||
|
@ -88,4 +89,7 @@ transform = Transform3D(0.499999, -0.000139169, -6.50204e-05, 5.24307e-05, 0.353
|
|||
[node name="Onboarding" parent="." instance=ExtResource("12_uq2nj")]
|
||||
transform = Transform3D(0.999999, -1.39632e-11, 0, 9.48097e-12, 0.999999, 0, 0, 0, 0.999999, -0.529594, 0.820154, -0.600147)
|
||||
|
||||
[node name="Test" parent="." instance=ExtResource("13_eg13b")]
|
||||
transform = Transform3D(-0.0709227, 0.000321724, 0.997481, 0.000312568, 1, -0.000300313, -0.997482, 0.000290482, -0.0709229, -0.0248237, 0.934686, -0.49358)
|
||||
|
||||
[editable path="XROrigin3D/XRControllerLeft"]
|
||||
|
|
33
app/content/ui/glass.gdshader
Normal file
33
app/content/ui/glass.gdshader
Normal file
|
@ -0,0 +1,33 @@
|
|||
shader_type spatial;
|
||||
|
||||
uniform vec4 color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
uniform vec2 size = vec2(1.0, 1.0);
|
||||
uniform float border_size = 0.1;
|
||||
uniform float border_fade_in: hint_range(0.0, 10.0) = 0.0;
|
||||
uniform float border_fade_out: hint_range(0.0, 10.0) = 0.0;
|
||||
uniform float corner_radius = 0.0;
|
||||
|
||||
float rectangle(vec2 position) {
|
||||
vec2 component_wise_edge_distance = abs(position) - (vec2(0.5, 0.5) * size + corner_radius * (size - 1.0));
|
||||
float outsideDistance = length(max(component_wise_edge_distance, 0));
|
||||
float insideDistance = min(max(component_wise_edge_distance.x, component_wise_edge_distance.y), 0);
|
||||
return outsideDistance + insideDistance;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = color.xyz;
|
||||
float border_scale = 1.0 + 2.0 * corner_radius;
|
||||
float d = rectangle((UV - 0.5) * size * border_scale);
|
||||
float border_width = (border_size + border_fade_in + border_fade_out) * border_scale;
|
||||
|
||||
if (d >= corner_radius - border_width && d <= corner_radius) {
|
||||
// Inside
|
||||
float rel_d = (d - corner_radius + border_width) / border_width;
|
||||
ALPHA = min((rel_d / (border_fade_in * border_scale / border_width)), (1.0 - (rel_d)) / (border_fade_out * border_scale / border_width));
|
||||
} else {
|
||||
// Outside
|
||||
ALPHA = 0.0;
|
||||
}
|
||||
|
||||
|
||||
}
|
39
app/content/ui/test.gd
Normal file
39
app/content/ui/test.gd
Normal file
|
@ -0,0 +1,39 @@
|
|||
extends Node3D
|
||||
|
||||
@onready var coll = $StaticBody3D/CollisionShape3D
|
||||
@onready var mesh = $StaticBody3D/MeshInstance3D
|
||||
|
||||
@onready var slider = $StaticBody3D/Slider
|
||||
@onready var slider2 = $StaticBody3D/Slider2
|
||||
@onready var slider3 = $StaticBody3D/Slider3
|
||||
@onready var slider4 = $StaticBody3D/Slider4
|
||||
@onready var slider5 = $StaticBody3D/Slider5
|
||||
@onready var slider6 = $StaticBody3D/Slider6
|
||||
|
||||
func _ready():
|
||||
slider.on_value_changed.connect(func(value):
|
||||
mesh.mesh.size.x=value
|
||||
coll.shape.size.x=value
|
||||
mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y))
|
||||
)
|
||||
slider2.on_value_changed.connect(func(value):
|
||||
mesh.mesh.size.y=value
|
||||
coll.shape.size.y=value
|
||||
mesh.material_override.set_shader_parameter("size", Vector2(mesh.mesh.size.x, mesh.mesh.size.y))
|
||||
)
|
||||
|
||||
slider3.on_value_changed.connect(func(value):
|
||||
mesh.material_override.set_shader_parameter("border_size", value)
|
||||
)
|
||||
|
||||
slider4.on_value_changed.connect(func(value):
|
||||
mesh.material_override.set_shader_parameter("corner_radius", value)
|
||||
)
|
||||
|
||||
slider5.on_value_changed.connect(func(value):
|
||||
mesh.material_override.set_shader_parameter("border_fade_in", value)
|
||||
)
|
||||
|
||||
slider6.on_value_changed.connect(func(value):
|
||||
mesh.material_override.set_shader_parameter("border_fade_out", value)
|
||||
)
|
72
app/content/ui/test.tscn
Normal file
72
app/content/ui/test.tscn
Normal file
|
@ -0,0 +1,72 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://dclceqjqfxekx"]
|
||||
|
||||
[ext_resource type="Script" path="res://content/ui/test.gd" id="1_jevji"]
|
||||
[ext_resource type="Shader" path="res://content/ui/glass.gdshader" id="1_p0dkh"]
|
||||
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="3_f40pk"]
|
||||
[ext_resource type="Script" path="res://content/functions/movable.gd" id="4_qjv7o"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_ptbst"]
|
||||
size = Vector3(2, 1, 0.1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xoqnh"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_p0dkh")
|
||||
shader_parameter/color = Color(1, 1, 1, 1)
|
||||
shader_parameter/size = Vector2(2, 1)
|
||||
shader_parameter/border_size = 0.04
|
||||
shader_parameter/border_fade_in = 0.07
|
||||
shader_parameter/border_fade_out = 0.0
|
||||
shader_parameter/corner_radius = 3.435
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_4253w"]
|
||||
size = Vector2(2, 1)
|
||||
|
||||
[node name="Test" type="Node3D"]
|
||||
script = ExtResource("1_jevji")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.07)
|
||||
shape = SubResource("BoxShape3D_ptbst")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
||||
material_override = SubResource("ShaderMaterial_xoqnh")
|
||||
mesh = SubResource("QuadMesh_4253w")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="Slider" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0, 0, 0)
|
||||
min = 0.1
|
||||
max = 2.0
|
||||
value = 1.0
|
||||
show_label = true
|
||||
label_unit = "w"
|
||||
|
||||
[node name="Slider2" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.0884458, 0, 0)
|
||||
min = 0.1
|
||||
max = 2.0
|
||||
value = 1.0
|
||||
show_label = true
|
||||
label_unit = "h"
|
||||
|
||||
[node name="Slider3" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.179572, 0, 0)
|
||||
show_label = true
|
||||
label_unit = "s"
|
||||
|
||||
[node name="Slider4" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.277398, 0, 0)
|
||||
max = 10.0
|
||||
show_label = true
|
||||
label_unit = "c"
|
||||
|
||||
[node name="Slider5" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.368523, 0, 0)
|
||||
|
||||
[node name="Slider6" parent="StaticBody3D" instance=ExtResource("3_f40pk")]
|
||||
transform = Transform3D(-4.37114e-08, 4.37114e-08, 1, 1, 1.91069e-15, 4.37114e-08, 0, 1, -4.37114e-08, 0.458309, 0, 0)
|
||||
|
||||
[node name="Movable" type="Node" parent="StaticBody3D"]
|
||||
script = ExtResource("4_qjv7o")
|
Loading…
Reference in New Issue
Block a user