From 2cc144229ff631c25c99664f470b17ff4360fb0c Mon Sep 17 00:00:00 2001 From: Daniel Snider Date: Thu, 18 Aug 2022 21:56:17 -0700 Subject: [PATCH] Add wipe to stomachs --- scenes/player.tscn | 29 +++++++++++++++++++++++++++-- shaders/circlewipe.gdshader | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 shaders/circlewipe.gdshader diff --git a/scenes/player.tscn b/scenes/player.tscn index 1499b1d..9469523 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=30 format=2] +[gd_scene load_steps=35 format=2] [ext_resource path="res://scripts/player/player.gd" type="Script" id=1] [ext_resource path="res://assets/dungman/DungMan.tscn" type="PackedScene" id=2] [ext_resource path="res://assets/icons/stomach.png" type="Texture" id=3] [ext_resource path="res://assets/dungman/Dungee_MAT.material" type="Material" id=4] +[ext_resource path="res://shaders/circlewipe.gdshader" type="Shader" id=5] [sub_resource type="ArrayMesh" id=1] resource_name = "DungMan_Mesh" @@ -683,6 +684,22 @@ colors = PoolColorArray( 0, 0, 0, 1, 0, 0, 0, 0.429105, 0, 0, 0, 0 ) gradient = SubResource( 20 ) fill_to = Vector2( 0, 1 ) +[sub_resource type="ShaderMaterial" id=28] +shader = ExtResource( 5 ) +shader_param/percent = 0.0 + +[sub_resource type="ShaderMaterial" id=29] +shader = ExtResource( 5 ) +shader_param/percent = 0.0 + +[sub_resource type="ShaderMaterial" id=30] +shader = ExtResource( 5 ) +shader_param/percent = 0.0 + +[sub_resource type="ShaderMaterial" id=31] +shader = ExtResource( 5 ) +shader_param/percent = 0.31 + [node name="Player" type="KinematicBody" groups=["player"]] axis_lock_motion_y = true move_lock_y = true @@ -697,7 +714,7 @@ mesh = SubResource( 1 ) skin = SubResource( 2 ) [node name="head_bone" type="BoneAttachment" parent="model_transform/DungMan/Armature/Skeleton" index="1"] -transform = Transform( 1, -2.22044e-16, -4.27702e-19, 2.64698e-23, -0.00192609, 0.999998, -2.22045e-16, -0.999998, -0.00192609, -3.33198e-16, 0.00261936, -1.49514 ) +transform = Transform( 1, -2.21988e-16, 5.59982e-18, -6.93938e-20, 0.0249053, 0.99969, -2.22059e-16, -0.99969, 0.0249053, -3.32446e-16, -0.0244905, -1.49896 ) bone_name = "Item" [node name="ItemSpawn" type="Spatial" parent="model_transform/DungMan/Armature/Skeleton/head_bone"] @@ -778,26 +795,34 @@ margin_right = 540.0 margin_bottom = 144.0 [node name="stomach0" type="TextureRect" parent="UI/Control/MarginContainer/stomachs"] +material = SubResource( 28 ) margin_right = 128.0 margin_bottom = 128.0 +rect_pivot_offset = Vector2( 128, 821 ) texture = ExtResource( 3 ) [node name="stomach1" type="TextureRect" parent="UI/Control/MarginContainer/stomachs"] +material = SubResource( 29 ) margin_left = 132.0 margin_right = 260.0 margin_bottom = 128.0 +rect_pivot_offset = Vector2( 128, 821 ) texture = ExtResource( 3 ) [node name="stomach2" type="TextureRect" parent="UI/Control/MarginContainer/stomachs"] +material = SubResource( 30 ) margin_left = 264.0 margin_right = 392.0 margin_bottom = 128.0 +rect_pivot_offset = Vector2( 128, 821 ) texture = ExtResource( 3 ) [node name="stomach3" type="TextureRect" parent="UI/Control/MarginContainer/stomachs"] +material = SubResource( 31 ) margin_left = 396.0 margin_right = 524.0 margin_bottom = 128.0 +rect_pivot_offset = Vector2( 128, 821 ) texture = ExtResource( 3 ) [node name="blackout" type="ColorRect" parent="UI"] diff --git a/shaders/circlewipe.gdshader b/shaders/circlewipe.gdshader new file mode 100644 index 0000000..d20fabd --- /dev/null +++ b/shaders/circlewipe.gdshader @@ -0,0 +1,19 @@ +shader_type canvas_item; + +uniform float percent; + +float atan2(in float y, in float x) { + bool s = (abs(x) > abs(y)); + if (s) { + return 3.14159/2.0 - atan(x,y); + } else { + return atan(y,x); + } +} + +void fragment() { + float angle = atan2((UV.y - 0.5) , (UV.x - 0.5)); + float alpha = step(percent * 3.14159 * 2.25, angle + 3.14159); + vec4 color = texture(TEXTURE, UV); + COLOR = vec4(color.rgb, color.a * alpha); +} \ No newline at end of file