From 52e3db30412695b42e13c0cf1c2381bb782b46cc Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sat, 27 Jan 2024 01:15:01 +0100 Subject: [PATCH] Using viewport texture instead of manual rect blending --- assets/textures/player_bomb_mask.png | Bin 0 -> 4336 bytes assets/textures/player_bomb_mask.png.import | 34 ++++++++++++++++ entities/Player.gd | 8 +++- materials/GrassNoiseMaterial.tres | 5 +-- materials/shader/WorldColoring.gdshader | 9 ++++- project.godot | 2 +- scenes/World.gd | 40 ++++++++----------- scenes/World.tscn | 41 ++++++++++++++++---- 8 files changed, 99 insertions(+), 40 deletions(-) create mode 100644 assets/textures/player_bomb_mask.png create mode 100644 assets/textures/player_bomb_mask.png.import diff --git a/assets/textures/player_bomb_mask.png b/assets/textures/player_bomb_mask.png new file mode 100644 index 0000000000000000000000000000000000000000..b04a8b0fc79cd06ed88136c6e8672f5f9ba6b8e5 GIT binary patch literal 4336 zcmVEX>4Tx04R}tkv&MmP!xqvTcsiuL90k{$WWauh>AFB6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~?BJy6A|>9J6k5c1;qgAsyXWxUeSp7SW~$jS4yc-C zq!Mub`5 zkz)ZBsE`~#_#gb9t(l*kaFarDp!3DHKSqGyF3_mi_V=-EH%@@SGjOG~{FOQ|^GSNG zrA3c`-fiIGx~0i`z~v4w^rTCM^3A z0;2`WUiWx+SNq)l?P<>M2T)gXnGy{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2j~GC016(ATOWu3000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}000ihNklLkkAMCU3(v&`6%=n0VwqR0gSH(B7A}1QTQnM zNWzaG^d|V|a6SW2;CIE$vI9o>Y9PWF3Vr~=x1STeHUc9$r^xiWz%xJa_my6MIuPL# zsRjk#gr7j@aea*Ia{{5KD*#y5pEH5cUN7*Rl~sHu2;q~oJ`%MIAbb{jG_ySb)ZVY_ zvpQxt*8-1BfK02PX8>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{U6XT3Nvf8qvQ1gp=vzr}2X34rCdFXqOP6k(J45ROHnXg5dTl`~haqW_q=YiNcwQGKc4knOaUj zKWGK0{S!FhyLMQ-wkM1LpcS0fFL!D3Ak(=y>8e0;K~z80b_InTa&g+6*~x2;6jV$i z}dc%UciO9Ba{%-wv%4rtS$0G{tu%5V2Kvb){J&R< zZ4|`?y83DR1(6kSA_9t5s-lii=1}X2IdZBF2t~y9yq7du!--xWSMC1^;pb%M^FQ@V zH|-N3)C&L{Ky#9v&-BbtM^X#6qv#p%a-{5(7#0#dM>#Fb{I!DcbA3G%{bYOarrwX( zx>#*iR0x2kfd~7zUjweVpG{90^V&0B>7GTGP0bV)YNsLyEz&uH;Mp(y{>+!zIT!qa ziJq$2`8Z3{zHg$fH`>Rgpvm-YOiTb^g7;N@pC{;!@HmND(AoV3UT*Jb>Km970U;1= zlMCEMYZ1c7`5?7{t5=Hf`n@==a)KP@NL;^=zj!F;KZAmP51@iis3IFx(`yLCLc&)Y zs|MkOc{3)ghH|m&L^1z~@&azMKb-T=WcTO~6x$l}VmsVftL>=Lwm3VOUIt|sEP$Iw zCWPK7CsV?u9P+2#MdR7GFbN`}!E!|dA`%e%VBQ}@rPl1@5LOnUCf`S9Hvc{{PrGTu z(*Xbw%=BV!T<6s^erM;a&+!gQ+`bG@=jR*v1W_X=h9%@tVg(9NtBAd{lvR$qAQExm%5?@Jy(EmEgYwfGfdZZC7(d#cBTZR_eUWjXb{;00#&&J;tKG zt6ItEEyDYdD8ABtg`* void: var material = mesh_instance.get_active_material(0) if not material: return + + material.next_pass = world_coloring_material - var world_coloring_pass :ShaderMaterial = material.next_pass as ShaderMaterial - world_coloring_pass.set_shader_parameter("world_color_texture", world_coloring_texture) - +func player_bomb_triggered(player): + world_coloring_player1_bomb_sprite.global_position = player_position_to_world_coloring_position(player.global_position) + world_coloring_player1_bomb_sprite.visible = true diff --git a/scenes/World.tscn b/scenes/World.tscn index a2a10d4..7d776bb 100644 --- a/scenes/World.tscn +++ b/scenes/World.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=14 format=3 uid="uid://b1nm5h3yccr16"] +[gd_scene load_steps=16 format=3 uid="uid://b1nm5h3yccr16"] [ext_resource type="Script" path="res://entities/Player.gd" id="1_ca7jo"] [ext_resource type="Script" path="res://scenes/World.gd" id="1_gtcjp"] [ext_resource type="Texture2D" uid="uid://cek45oeqv3jvj" path="res://assets/textures/test_world_color_texture_viewport.png" id="3_bvxb7"] [ext_resource type="Texture2D" uid="uid://bnsrnuuq28p4d" path="res://assets/textures/player_draw_mask.png" id="4_dipd5"] [ext_resource type="Material" uid="uid://bg3dawo5kkosg" path="res://materials/GrassNoiseMaterial.tres" id="4_pseda"] +[ext_resource type="Texture2D" uid="uid://vcebfpqo2ko7" path="res://assets/textures/player_bomb_mask.png" id="5_17c1g"] [sub_resource type="BoxMesh" id="BoxMesh_yle83"] size = Vector3(0.24, 0.75, 0.24) @@ -22,7 +23,11 @@ ambient_light_energy = 2.64 [sub_resource type="BoxShape3D" id="BoxShape3D_p0rqu"] +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mr6ph"] +albedo_color = Color(1, 0.137255, 1, 1) + [sub_resource type="BoxMesh" id="BoxMesh_237xr"] +material = SubResource("StandardMaterial3D_mr6ph") [sub_resource type="BoxMesh" id="BoxMesh_bwn4a"] material = ExtResource("4_pseda") @@ -36,12 +41,12 @@ script = ExtResource("1_gtcjp") [node name="Player1" type="CharacterBody3D" parent="."] collision_mask = 3 script = ExtResource("1_ca7jo") -color = null move_right_action = "move_right_p1" move_left_action = "move_left_p1" move_down_action = "move_down_p1" move_up_action = "move_up_p1" -dash_action = null +dash_action = "dash_p1" +bomb_action = "bomb_p1" [node name="Geometry" type="MeshInstance3D" parent="Player1"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.472544, 0) @@ -59,7 +64,7 @@ transform = Transform3D(-4.37114e-08, -0.528438, 0.848972, 0, 0.848972, 0.528438 shadow_enabled = true [node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.305147, 0.952305, 0, -0.952305, 0.305147, 0, 10, 1.966) +transform = Transform3D(1, 0, 0, 0, 0.305147, 0.952305, 0, -0.952305, 0.305147, 0, 10, 3.10854) [node name="Sprite3D" type="Sprite3D" parent="."] transform = Transform3D(20, 0, 0, 0, -8.74228e-07, 50, 0, -20, -2.18557e-06, 0, 0, 0) @@ -69,11 +74,13 @@ modulate = Color(1, 1, 1, 0.32549) own_world_3d = true world_3d = SubResource("World3D_s7kgt") transparent_bg = true -size = Vector2i(1001, 1001) +handle_input_locally = false +size = Vector2i(1000, 1000) render_target_clear_mode = 1 render_target_update_mode = 4 [node name="TextureRect" type="TextureRect" parent="WorldColoringViewport"] +visible = false anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -82,14 +89,32 @@ grow_vertical = 2 texture = ExtResource("3_bvxb7") [node name="Player1TextureRect" type="TextureRect" parent="WorldColoringViewport"] -offset_right = 40.0 -offset_bottom = 40.0 +visible = false +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 texture = ExtResource("4_dipd5") +[node name="Player1Sprite" type="Sprite2D" parent="WorldColoringViewport"] +texture = ExtResource("4_dipd5") + +[node name="Player1BombSprite" type="Sprite2D" parent="WorldColoringViewport"] +texture = ExtResource("5_17c1g") + [node name="Level" type="Node3D" parent="."] [node name="Box" type="StaticBody3D" parent="Level"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.38367, 0, 2.83298) [node name="CollisionShape3D" type="CollisionShape3D" parent="Level/Box"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)