mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-22 15:23:46 +00:00
Forcefield Shader
This commit is contained in:
parent
a13355be42
commit
f23d84071a
9 changed files with 210 additions and 14 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
[gd_scene load_steps=21 format=3 uid="uid://b0gpbkxdfbnjh"]
|
[gd_scene load_steps=24 format=3 uid="uid://b0gpbkxdfbnjh"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Door.cs" id="1_uxoep"]
|
[ext_resource type="Script" path="res://Scripts/Activables/ForceField.cs" id="1_yxhr6"]
|
||||||
[ext_resource type="Texture2D" uid="uid://gc24sjyj47x6" path="res://Sprites/Actors/ForceFieldHorizontal.png" id="2_12wxm"]
|
[ext_resource type="Texture2D" uid="uid://gc24sjyj47x6" path="res://Sprites/Actors/ForceFieldHorizontal.png" id="2_12wxm"]
|
||||||
|
[ext_resource type="Shader" path="res://Shaders/Blink.gdshader" id="2_q7pky"]
|
||||||
|
[ext_resource type="Shader" uid="uid://cjdl1m3psohju" path="res://Shaders/scanlines_static.tres" id="2_qbobr"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tnfy3"]
|
||||||
|
shader = ExtResource("2_qbobr")
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gecst"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gecst"]
|
||||||
atlas = ExtResource("2_12wxm")
|
atlas = ExtResource("2_12wxm")
|
||||||
|
|
@ -140,13 +145,16 @@ size = Vector2(32, 32)
|
||||||
[node name="HorizontalForceField" type="Area2D" groups=["Solid"]]
|
[node name="HorizontalForceField" type="Area2D" groups=["Solid"]]
|
||||||
collision_layer = 64
|
collision_layer = 64
|
||||||
collision_mask = 154
|
collision_mask = 154
|
||||||
script = ExtResource("1_uxoep")
|
script = ExtResource("1_yxhr6")
|
||||||
|
TurnOffShader = ExtResource("2_q7pky")
|
||||||
|
ActiveShader = ExtResource("2_qbobr")
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
modulate = Color(1, 1, 1, 0.784314)
|
modulate = Color(1, 1, 1, 0.784314)
|
||||||
|
material = SubResource("ShaderMaterial_tnfy3")
|
||||||
sprite_frames = SubResource("SpriteFrames_h2s1d")
|
sprite_frames = SubResource("SpriteFrames_h2s1d")
|
||||||
animation = &"Open"
|
animation = &"Closed"
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ autoplay = "default"
|
||||||
frame_progress = 0.193815
|
frame_progress = 0.193815
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
visible = false
|
||||||
shape = SubResource("RectangleShape2D_0nhpj")
|
shape = SubResource("RectangleShape2D_0nhpj")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||||
|
|
@ -56,5 +57,6 @@ collision_mask = 10
|
||||||
gravity_scale = 0.0
|
gravity_scale = 0.0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
|
visible = false
|
||||||
position = Vector2(0.5, -3)
|
position = Vector2(0.5, -3)
|
||||||
shape = SubResource("RectangleShape2D_vguns")
|
shape = SubResource("RectangleShape2D_vguns")
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ sprite_frames = SubResource("SpriteFrames_8ejte")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
visible = false
|
||||||
shape = SubResource("RectangleShape2D_0nhpj")
|
shape = SubResource("RectangleShape2D_0nhpj")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||||
|
|
@ -55,5 +56,6 @@ collision_mask = 10
|
||||||
gravity_scale = 0.0
|
gravity_scale = 0.0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
|
visible = false
|
||||||
position = Vector2(0, -3)
|
position = Vector2(0, -3)
|
||||||
shape = SubResource("RectangleShape2D_vguns")
|
shape = SubResource("RectangleShape2D_vguns")
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,6 @@ collision_mask = 10
|
||||||
gravity_scale = 0.0
|
gravity_scale = 0.0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
|
visible = false
|
||||||
position = Vector2(1, -4)
|
position = Vector2(1, -4)
|
||||||
shape = SubResource("RectangleShape2D_vguns")
|
shape = SubResource("RectangleShape2D_vguns")
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
52
Scripts/Activables/ForceField.cs
Normal file
52
Scripts/Activables/ForceField.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using Cirno.Scripts;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public partial class ForceField : Door
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public Shader TurnOffShader { get; private set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Shader ActiveShader { get; private set; }
|
||||||
|
|
||||||
|
// Disable
|
||||||
|
public override void Open()
|
||||||
|
{
|
||||||
|
base.Open();
|
||||||
|
if (TurnOffShader is null) return;
|
||||||
|
|
||||||
|
((ShaderMaterial)_animatedSprite.Material).Shader = TurnOffShader;
|
||||||
|
|
||||||
|
_ = AnimateShutdownAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task AnimateShutdownAsync()
|
||||||
|
{
|
||||||
|
Tween tween = GetTree().CreateTween();
|
||||||
|
tween.TweenMethod(Callable.From((float value) => SetShaderScanlineDensity(value)), 0f, 50f, 0.5);
|
||||||
|
tween.Parallel().TweenMethod(Callable.From((float value) => SetShaderTeleportProgress(value)), 0f, 1f, 0.5);
|
||||||
|
|
||||||
|
await ToSignal(tween, "finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
base.Close();
|
||||||
|
|
||||||
|
if (ActiveShader is null) return;
|
||||||
|
((ShaderMaterial)_animatedSprite.Material).Shader = ActiveShader;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetShaderTeleportProgress(float value)
|
||||||
|
{
|
||||||
|
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("teleport_progress", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetShaderScanlineDensity(float value)
|
||||||
|
{
|
||||||
|
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("scanline_density", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,9 +5,9 @@ using Cirno.Scripts;
|
||||||
|
|
||||||
public partial class Door : Activable
|
public partial class Door : Activable
|
||||||
{
|
{
|
||||||
private AnimatedSprite2D _animatedSprite;
|
protected AnimatedSprite2D _animatedSprite;
|
||||||
private CollisionShape2D _collisionShape;
|
protected CollisionShape2D _collisionShape;
|
||||||
private CollisionShape2D _solidShape;
|
protected CollisionShape2D _solidShape;
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
|
|
@ -27,7 +27,7 @@ public partial class Door : Activable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Open()
|
public virtual void Open()
|
||||||
{
|
{
|
||||||
_animatedSprite.Play("Opening");
|
_animatedSprite.Play("Opening");
|
||||||
State = DoorState.Open;
|
State = DoorState.Open;
|
||||||
|
|
@ -36,7 +36,7 @@ public partial class Door : Activable
|
||||||
//_solidShape.Disabled = true;
|
//_solidShape.Disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
_animatedSprite.Play("Closing");
|
_animatedSprite.Play("Closing");
|
||||||
State = DoorState.Closed;
|
State = DoorState.Closed;
|
||||||
|
|
|
||||||
116
Shaders/scanlines_static.tres
Normal file
116
Shaders/scanlines_static.tres
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
[gd_resource type="VisualShader" load_steps=11 format=3 uid="uid://cjdl1m3psohju"]
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeFloatOp" id="VisualShaderNodeFloatOp_7rr75"]
|
||||||
|
default_input_values = [0, 0.0, 1, 5.0]
|
||||||
|
operator = 2
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeFloatOp" id="VisualShaderNodeFloatOp_own43"]
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_stwjs"]
|
||||||
|
input_name = "uv"
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeVectorDecompose" id="VisualShaderNodeVectorDecompose_kafk8"]
|
||||||
|
default_input_values = [0, Vector2(0, 0)]
|
||||||
|
op_type = 0
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeFloatOp" id="VisualShaderNodeFloatOp_4ci11"]
|
||||||
|
default_input_values = [0, 0.0, 1, 100.0]
|
||||||
|
operator = 2
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeFloatFunc" id="VisualShaderNodeFloatFunc_5vgt5"]
|
||||||
|
function = 0
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_xwcy1"]
|
||||||
|
input_name = "texture"
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_c5icc"]
|
||||||
|
output_port_for_preview = 0
|
||||||
|
expanded_output_ports = [0]
|
||||||
|
source = 5
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeMix" id="VisualShaderNodeMix_6sm8i"]
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_81ys3"]
|
||||||
|
input_name = "time"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
code = "shader_type canvas_item;
|
||||||
|
render_mode blend_mix;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec4 n_out7p0;
|
||||||
|
// Texture2D:7
|
||||||
|
n_out7p0 = texture(TEXTURE, UV);
|
||||||
|
float n_out7p4 = n_out7p0.a;
|
||||||
|
|
||||||
|
|
||||||
|
// Input:2
|
||||||
|
vec2 n_out2p0 = UV;
|
||||||
|
|
||||||
|
|
||||||
|
// VectorDecompose:3
|
||||||
|
float n_out3p0 = n_out2p0.x;
|
||||||
|
float n_out3p1 = n_out2p0.y;
|
||||||
|
|
||||||
|
|
||||||
|
// FloatOp:4
|
||||||
|
float n_in4p1 = 100.00000;
|
||||||
|
float n_out4p0 = n_out3p1 * n_in4p1;
|
||||||
|
|
||||||
|
|
||||||
|
// Input:9
|
||||||
|
float n_out9p0 = TIME;
|
||||||
|
|
||||||
|
|
||||||
|
// FloatOp:10
|
||||||
|
float n_in10p1 = 5.00000;
|
||||||
|
float n_out10p0 = n_out9p0 * n_in10p1;
|
||||||
|
|
||||||
|
|
||||||
|
// FloatOp:11
|
||||||
|
float n_out11p0 = n_out4p0 + n_out10p0;
|
||||||
|
|
||||||
|
|
||||||
|
// FloatFunc:5
|
||||||
|
float n_out5p0 = sin(n_out11p0);
|
||||||
|
|
||||||
|
|
||||||
|
// Mix:8
|
||||||
|
float n_in8p2 = 0.50000;
|
||||||
|
float n_out8p0 = mix(n_out7p4, n_out5p0, n_in8p2);
|
||||||
|
|
||||||
|
|
||||||
|
// Output:0
|
||||||
|
COLOR.a = n_out8p0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
"
|
||||||
|
graph_offset = Vector2(-10.9562, 180.832)
|
||||||
|
mode = 1
|
||||||
|
flags/light_only = false
|
||||||
|
nodes/fragment/0/position = Vector2(2520, 280)
|
||||||
|
nodes/fragment/2/node = SubResource("VisualShaderNodeInput_stwjs")
|
||||||
|
nodes/fragment/2/position = Vector2(60, 240)
|
||||||
|
nodes/fragment/3/node = SubResource("VisualShaderNodeVectorDecompose_kafk8")
|
||||||
|
nodes/fragment/3/position = Vector2(560, 280)
|
||||||
|
nodes/fragment/4/node = SubResource("VisualShaderNodeFloatOp_4ci11")
|
||||||
|
nodes/fragment/4/position = Vector2(880, 440)
|
||||||
|
nodes/fragment/5/node = SubResource("VisualShaderNodeFloatFunc_5vgt5")
|
||||||
|
nodes/fragment/5/position = Vector2(1760, 360)
|
||||||
|
nodes/fragment/6/node = SubResource("VisualShaderNodeInput_xwcy1")
|
||||||
|
nodes/fragment/6/position = Vector2(480, 1300)
|
||||||
|
nodes/fragment/7/node = SubResource("VisualShaderNodeTexture_c5icc")
|
||||||
|
nodes/fragment/7/position = Vector2(1200, 1160)
|
||||||
|
nodes/fragment/8/node = SubResource("VisualShaderNodeMix_6sm8i")
|
||||||
|
nodes/fragment/8/position = Vector2(2040, 860)
|
||||||
|
nodes/fragment/9/node = SubResource("VisualShaderNodeInput_81ys3")
|
||||||
|
nodes/fragment/9/position = Vector2(300, 660)
|
||||||
|
nodes/fragment/10/node = SubResource("VisualShaderNodeFloatOp_7rr75")
|
||||||
|
nodes/fragment/10/position = Vector2(880, 800)
|
||||||
|
nodes/fragment/11/node = SubResource("VisualShaderNodeFloatOp_own43")
|
||||||
|
nodes/fragment/11/position = Vector2(1360, 480)
|
||||||
|
nodes/fragment/connections = PackedInt32Array(2, 0, 3, 0, 3, 1, 4, 0, 6, 0, 7, 2, 7, 4, 8, 0, 5, 0, 8, 1, 8, 0, 0, 1, 9, 0, 10, 0, 4, 0, 11, 0, 10, 0, 11, 1, 11, 0, 5, 0)
|
||||||
|
|
@ -867,13 +867,21 @@ texture = ExtResource("1_70kxh")
|
||||||
10:14/0 = 0
|
10:14/0 = 0
|
||||||
10:15/0 = 0
|
10:15/0 = 0
|
||||||
6:14/0 = 0
|
6:14/0 = 0
|
||||||
|
6:14/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
7:14/0 = 0
|
7:14/0 = 0
|
||||||
|
7:14/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
8:14/0 = 0
|
8:14/0 = 0
|
||||||
|
8:14/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
9:14/0 = 0
|
9:14/0 = 0
|
||||||
|
9:14/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
9:15/0 = 0
|
9:15/0 = 0
|
||||||
|
9:15/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
8:15/0 = 0
|
8:15/0 = 0
|
||||||
|
8:15/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
7:15/0 = 0
|
7:15/0 = 0
|
||||||
|
7:15/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
6:15/0 = 0
|
6:15/0 = 0
|
||||||
|
6:15/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
|
|
||||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_qg3vu"]
|
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_qg3vu"]
|
||||||
resource_name = "Props"
|
resource_name = "Props"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue