From 66bd12dffb6afe994c007885d183a4a5a95a7ce1 Mon Sep 17 00:00:00 2001 From: msk <15199219+muskit@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:22:48 -0700 Subject: [PATCH] make SwipeArrow color changing part of the shader parameter --- Scenes/Play.tscn | 11 ++--- Scripts/Things/TunnelObjects/SwipeArrow.cs | 5 +- Shaders/SwipeArrow.tres | 49 +++++++++++++++----- Things/TunnelObjects/Notes/NoteSwipeCCW.tscn | 3 +- Things/TunnelObjects/Notes/NoteSwipeCW.tscn | 7 ++- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Scenes/Play.tscn b/Scenes/Play.tscn index 49ff1c4..86252d1 100644 --- a/Scenes/Play.tscn +++ b/Scenes/Play.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=20 format=3 uid="uid://bqh00ot0csqmk"] +[gd_scene load_steps=19 format=3 uid="uid://bqh00ot0csqmk"] [ext_resource type="Script" path="res://Scripts/Scenes/Play/Play.cs" id="1_asytu"] [ext_resource type="PackedScene" uid="uid://cyetvgmwnoy8l" path="res://Things/Background.tscn" id="2_8g6gv"] [ext_resource type="Texture2D" uid="uid://cfvv520hv5lss" path="res://_Assets/Textures/background-placeholder.jpg" id="2_k05nq"] [ext_resource type="Shader" path="res://Shaders/Cutout2D.gdshader" id="3_rjbyl"] [ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/BGM.cs" id="4_c2dke"] -[ext_resource type="PackedScene" uid="uid://wk634bobe32k" path="res://Things/TunnelObjects/Notes/NoteSwipeCW.tscn" id="5_bea86"] [ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/SFX.cs" id="5_owrd5"] [sub_resource type="Environment" id="Environment_nefjb"] @@ -65,7 +64,7 @@ uv1_offset = Vector3(0, -0.001, 0) [sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"] viewport_path = NodePath("Mask") -[sub_resource type="ShaderMaterial" id="ShaderMaterial_5k3bq"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_qewlm"] resource_local_to_scene = true shader = ExtResource("3_rjbyl") shader_parameter/mask = SubResource("ViewportTexture_w20vk") @@ -163,7 +162,7 @@ anchor_mode = 0 editor_draw_screen = false [node name="Background" parent="2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")] -material = SubResource("ShaderMaterial_5k3bq") +material = SubResource("ShaderMaterial_qewlm") layout_mode = 1 offset_top = -1920.0 offset_right = 1920.0 @@ -271,10 +270,6 @@ anchor_top = 1.0 anchor_bottom = 1.0 grow_vertical = 0 -[node name="NoteSwipeCW" parent="2D Viewport/Viewport Control/Scroll Anchor/Notes Scroll" instance=ExtResource("5_bea86")] -offset_top = -1798.51 -offset_bottom = -1774.51 - [node name="AudioStreamPlayer BGM" type="AudioStreamPlayer" parent="."] script = ExtResource("4_c2dke") diff --git a/Scripts/Things/TunnelObjects/SwipeArrow.cs b/Scripts/Things/TunnelObjects/SwipeArrow.cs index 30f3d7f..40302d1 100644 --- a/Scripts/Things/TunnelObjects/SwipeArrow.cs +++ b/Scripts/Things/TunnelObjects/SwipeArrow.cs @@ -6,8 +6,6 @@ namespace WacK.Things.TunnelObjects [Tool] public partial class SwipeArrow : Control { - public readonly Color COLOR_CW = new("#FF8000"); // TODO: adjust - public readonly Color COLOR_CCW = new("#00FF00"); private ShaderMaterial shader; @@ -18,8 +16,7 @@ namespace WacK.Things.TunnelObjects public void SetCW(bool isCW) { - shader.SetShaderParameter("ArrowColor", isCW ? COLOR_CW : COLOR_CCW); - shader.SetShaderParameter("isCwShape", isCW); + shader.SetShaderParameter("isCw", isCW); } public void SetPosSize(int pos, int size) diff --git a/Shaders/SwipeArrow.tres b/Shaders/SwipeArrow.tres index 31a8260..6d2a78f 100644 --- a/Shaders/SwipeArrow.tres +++ b/Shaders/SwipeArrow.tres @@ -1,4 +1,4 @@ -[gd_resource type="VisualShader" load_steps=27 format=3 uid="uid://dm5rgp78v61ha"] +[gd_resource type="VisualShader" load_steps=30 format=3 uid="uid://dm5rgp78v61ha"] [ext_resource type="Texture2D" uid="uid://cmaq66vbi80ug" path="res://_Assets/Textures/Notes/SlideArrow_Texture.png" id="1_cj2ec"] [ext_resource type="Texture2D" uid="uid://kjoqem41xatr" path="res://_Assets/Textures/Notes/SlideArrow_Mask.png" id="2_p52jd"] @@ -98,6 +98,16 @@ parameter_name = "TileMult" default_value_enabled = true default_value = 6.0 +[sub_resource type="VisualShaderNodeSwitch" id="VisualShaderNodeSwitch_2ma3x"] +default_input_values = [0, false, 1, Quaternion(1, 1, 1, 1), 2, Quaternion(0, 0, 0, 0)] +op_type = 5 + +[sub_resource type="VisualShaderNodeColorConstant" id="VisualShaderNodeColorConstant_e28fg"] +constant = Color(1, 0.584314, 0, 1) + +[sub_resource type="VisualShaderNodeColorConstant" id="VisualShaderNodeColorConstant_uf0bo"] +constant = Color(0, 1, 0, 1) + [sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_13pou"] default_input_values = [0, Quaternion(0, 0, 0, 0), 1, Quaternion(0, 0, 0, 0)] op_type = 2 @@ -112,7 +122,6 @@ operator = 2 code = "shader_type canvas_item; render_mode blend_mix; -uniform vec4 ArrowColor : source_color = vec4(0.000000, 1.000000, 0.000000, 1.000000); uniform bool isCwShape = false; uniform float TileMult = 6; uniform float scrollMultiplier = 1; @@ -122,17 +131,26 @@ uniform sampler2D mask : hint_default_transparent, filter_linear_mipmap; void fragment() { -// ColorParameter:29 - vec4 n_out29p0 = ArrowColor; +// BooleanParameter:35 + bool n_out35p0 = isCwShape; + + +// ColorConstant:40 + vec4 n_out40p0 = vec4(1.000000, 0.584314, 0.000000, 1.000000); + + +// ColorConstant:41 + vec4 n_out41p0 = vec4(0.000000, 1.000000, 0.000000, 1.000000); + + + vec4 n_out39p0; +// Switch:39 + n_out39p0 = mix(n_out41p0, n_out40p0, float(n_out35p0)); // VectorOp:13 vec4 n_in13p1 = vec4(2.00000, 2.00000, 2.00000, 2.00000); - vec4 n_out13p0 = n_out29p0 * n_in13p1; - - -// BooleanParameter:35 - bool n_out35p0 = isCwShape; + vec4 n_out13p0 = n_out39p0 * n_in13p1; // Input:20 @@ -191,7 +209,7 @@ void fragment() { // VectorOp:10 - vec4 n_out10p0 = n_out11p0 + n_out29p0; + vec4 n_out10p0 = n_out11p0 + n_out39p0; vec4 n_out16p0; @@ -230,6 +248,7 @@ void fragment() { } " +graph_offset = Vector2(-1381.11, -324.544) mode = 1 flags/light_only = false nodes/fragment/0/position = Vector2(1500, 460) @@ -244,7 +263,7 @@ nodes/fragment/10/position = Vector2(560, -80) nodes/fragment/11/node = SubResource("VisualShaderNodeVectorOp_3pdfb") nodes/fragment/11/position = Vector2(280, -160) nodes/fragment/13/node = SubResource("VisualShaderNodeVectorOp_eesut") -nodes/fragment/13/position = Vector2(60, -220) +nodes/fragment/13/position = Vector2(-20, -260) nodes/fragment/14/node = SubResource("VisualShaderNodeTexture_2u62d") nodes/fragment/14/position = Vector2(-60, 120) nodes/fragment/15/node = SubResource("VisualShaderNodeFloatOp_nqoll") @@ -281,4 +300,10 @@ nodes/fragment/37/node = SubResource("VisualShaderNodeSwitch_si863") nodes/fragment/37/position = Vector2(-1020, -20) nodes/fragment/38/node = SubResource("VisualShaderNodeFloatParameter_2lm10") nodes/fragment/38/position = Vector2(-1380, 280) -nodes/fragment/connections = PackedInt32Array(7, 0, 8, 0, 11, 0, 10, 0, 10, 0, 7, 0, 13, 0, 11, 0, 15, 0, 7, 1, 16, 1, 17, 1, 16, 3, 15, 1, 16, 2, 3, 2, 8, 0, 0, 0, 22, 0, 14, 0, 3, 0, 8, 1, 17, 0, 0, 1, 14, 1, 11, 1, 14, 1, 15, 0, 14, 2, 3, 0, 26, 0, 14, 2, 27, 0, 24, 1, 28, 0, 27, 1, 29, 0, 13, 0, 29, 0, 10, 1, 14, 3, 17, 0, 30, 0, 16, 2, 23, 0, 27, 0, 32, 0, 22, 1, 24, 0, 22, 2, 20, 0, 36, 0, 35, 0, 37, 0, 37, 0, 22, 0, 37, 0, 16, 0, 38, 0, 32, 1, 36, 0, 37, 1, 20, 0, 37, 2) +nodes/fragment/39/node = SubResource("VisualShaderNodeSwitch_2ma3x") +nodes/fragment/39/position = Vector2(-420, -220) +nodes/fragment/40/node = SubResource("VisualShaderNodeColorConstant_e28fg") +nodes/fragment/40/position = Vector2(-740, -260) +nodes/fragment/41/node = SubResource("VisualShaderNodeColorConstant_uf0bo") +nodes/fragment/41/position = Vector2(-800, -120) +nodes/fragment/connections = PackedInt32Array(7, 0, 8, 0, 11, 0, 10, 0, 10, 0, 7, 0, 13, 0, 11, 0, 15, 0, 7, 1, 16, 1, 17, 1, 16, 3, 15, 1, 16, 2, 3, 2, 8, 0, 0, 0, 22, 0, 14, 0, 3, 0, 8, 1, 17, 0, 0, 1, 14, 1, 11, 1, 14, 1, 15, 0, 14, 2, 3, 0, 26, 0, 14, 2, 27, 0, 24, 1, 28, 0, 27, 1, 29, 0, 13, 0, 29, 0, 10, 1, 14, 3, 17, 0, 30, 0, 16, 2, 23, 0, 27, 0, 32, 0, 22, 1, 24, 0, 22, 2, 20, 0, 36, 0, 35, 0, 37, 0, 37, 0, 22, 0, 37, 0, 16, 0, 38, 0, 32, 1, 36, 0, 37, 1, 20, 0, 37, 2, 35, 0, 39, 0, 40, 0, 39, 1, 41, 0, 39, 2, 39, 0, 13, 0, 39, 0, 10, 1) diff --git a/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn b/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn index ae9771a..e2b371d 100644 --- a/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn +++ b/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn @@ -10,8 +10,7 @@ [sub_resource type="ShaderMaterial" id="ShaderMaterial_6l1er"] resource_local_to_scene = true shader = ExtResource("3_k16x0") -shader_parameter/ArrowColor = Color(0, 1, 0, 1) -shader_parameter/isCwShape = false +shader_parameter/isCw = false shader_parameter/TileMult = 6.0 shader_parameter/scrollMultiplier = 2.0 shader_parameter/arrow = ExtResource("4_rv322") diff --git a/Things/TunnelObjects/Notes/NoteSwipeCW.tscn b/Things/TunnelObjects/Notes/NoteSwipeCW.tscn index 5267365..6fc26b7 100644 --- a/Things/TunnelObjects/Notes/NoteSwipeCW.tscn +++ b/Things/TunnelObjects/Notes/NoteSwipeCW.tscn @@ -7,11 +7,10 @@ [ext_resource type="Texture2D" uid="uid://cmaq66vbi80ug" path="res://_Assets/Textures/Notes/SlideArrow_Texture.png" id="4_v0t51"] [ext_resource type="Texture2D" uid="uid://kjoqem41xatr" path="res://_Assets/Textures/Notes/SlideArrow_Mask.png" id="5_dafyh"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_k510k"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ub4cc"] resource_local_to_scene = true shader = ExtResource("3_de2t7") -shader_parameter/ArrowColor = Color(0, 1, 0, 1) -shader_parameter/isCwShape = false +shader_parameter/isCwShape = true shader_parameter/TileMult = 6.0 shader_parameter/scrollMultiplier = 2.0 shader_parameter/arrow = ExtResource("4_v0t51") @@ -40,7 +39,7 @@ patch_margin_left = 12 patch_margin_right = 12 [node name="SwipeArrow" parent="." instance=ExtResource("3_b1dle")] -material = SubResource("ShaderMaterial_k510k") +material = SubResource("ShaderMaterial_ub4cc") layout_mode = 0 offset_top = -35.0 offset_bottom = 733.0