feat: implement water shader and environment for free mode arena

This commit is contained in:
Yogi Wiguna
2026-03-31 15:59:00 +08:00
parent 3454710f2c
commit 1e6da89fff
16 changed files with 337 additions and 116 deletions
+33
View File
@@ -1,8 +1,41 @@
[gd_scene format=3 uid="uid://nwpaqt6drdkr"]
[ext_resource type="PackedScene" uid="uid://b1l0x4yf3lbx8" path="res://assets/models/arena/free_mode/Terrainv2.gltf" id="1_37t6b"]
[ext_resource type="Material" uid="uid://xifgjdr8285d" path="res://assets/models/arena/free_mode/water_shader.tres" id="2_bw67x"]
[ext_resource type="Texture2D" uid="uid://dep1ng3aqb2jw" path="res://assets/models/arena/free_mode/sky_sea_01.png" id="3_8esiu"]
[sub_resource type="PlaneMesh" id="PlaneMesh_8esiu"]
material = ExtResource("2_bw67x")
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_xj13a"]
panorama = ExtResource("3_8esiu")
[sub_resource type="Sky" id="Sky_p4wg4"]
sky_material = SubResource("PanoramaSkyMaterial_xj13a")
[sub_resource type="Environment" id="Environment_8v6kw"]
background_mode = 2
sky = SubResource("Sky_p4wg4")
ambient_light_source = 3
ambient_light_color = Color(1, 1, 1, 1)
ambient_light_sky_contribution = 0.5
reflected_light_source = 2
[node name="Freemode" type="Node3D" unique_id=355029811]
transform = Transform3D(100, 0, 0, 0, 100, 0, 0, 0, 100, 10.565, -0.57, 8.139)
[node name="Terrainv2" parent="." unique_id=1519605696 instance=ExtResource("1_37t6b")]
[node name="Water" type="MeshInstance3D" parent="." unique_id=289309951]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.14561673, 0)
mesh = SubResource("PlaneMesh_8esiu")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=831804132]
transform = Transform3D(0.23387258, -0.9458177, 0.2252387, -0.400554, 0.11736052, 0.90872604, -0.88592327, -0.30274636, -0.35140368, 0.1, 0.1, 0.13)
light_color = Color(0.98039216, 0.83137256, 0.70980394, 1)
shadow_enabled = true
shadow_bias = 0.2
shadow_normal_bias = 5.0
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=936572897]
environment = SubResource("Environment_8v6kw")
+21 -16
View File
@@ -123,19 +123,11 @@ func _apply_arena_background():
"Stop N Go Arena":
texture_path = "res://assets/graphics/level_bg/placeholder_stop_n_go.jpg"
_instantiate_3d_arena("res://scenes/arena/stop_n_go.scn")
# Make normal, non-walkable, and Tekton floors invisible
# by shrinking their scale to 0. This hides them visually while
# avoiding "Parameter 'mesh' is null" or material override errors.
var em = $EnhancedGridMap
if em and em.mesh_library:
var ml = em.mesh_library.duplicate()
for id in [0, 4, 6]:
# Scale to 0 to hide it without triggering invalid mesh errors
ml.set_item_mesh_transform(id, Transform3D().scaled(Vector3.ZERO))
em.mesh_library = ml
print("[Main] Hide tiles 0, 4, 6 via zero-scale transform.")
_hide_ground_tiles()
"Freemode Arena":
texture_path = "res://assets/graphics/level_bg/placeholder_classic.jpg" # Fallback texture
_instantiate_3d_arena("res://scenes/arena/freemode.tscn")
_hide_ground_tiles()
"Tekton Doors Arena":
texture_path = "res://assets/graphics/level_bg/placeholder_tekton_doors.jpg"
"Classic", _:
@@ -159,6 +151,20 @@ func _instantiate_3d_arena(scene_path: String):
move_child(arena_instance, 0)
print("Instantiated 3D Arena: ", scene_path)
func _hide_ground_tiles():
# Make normal, non-walkable, and Tekton floors invisible
# by shrinking their scale to 0. This hides them visually while
# avoiding "Parameter 'mesh' is null" or material override errors.
var em = $EnhancedGridMap
if em and em.mesh_library:
var ml = em.mesh_library.duplicate()
for id in [0, 4, 6]:
# Scale to 0 to hide it without triggering invalid mesh errors
ml.set_item_mesh_transform(id, Transform3D().scaled(Vector3.ZERO))
em.mesh_library = ml
print("[Main] Hide tiles 0, 4, 6 via zero-scale transform.")
@rpc("any_peer", "call_local", "reliable")
func sync_portal_configs(configs: Array):
if portal_mode_manager:
@@ -849,11 +855,10 @@ func _assign_random_spawn_positions():
var pos = Vector2i(x, z)
# SAFETY CHECK: Is this reserved for a Static Tekton Stand?
# Stand clears 3x3, we use a strictly >= 1 check (so abs <= 1 is EXACTLY the 3x3 stand)
# Let's use a 3x3 check (1 radius) to avoid strictly the stand itself, plus 1 buffer = radius 2.
# Stand clears exactly 3x3 area
var is_safe = true
for reserved in reserved_static_positions:
if abs(x - reserved.x) <= 2 and abs(z - reserved.y) <= 2:
if abs(x - reserved.x) <= 1 and abs(z - reserved.y) <= 1:
is_safe = false
break
+3 -4
View File
@@ -1345,18 +1345,17 @@ func is_position_occupied(pos: Vector2i) -> bool:
if p.is_player_moving and p.target_position == pos:
return true
# Prevent overlap with Static Tekton Stands (3x3 area, with 1-tile buffer = 5x5 checked)
# Prevent overlap with Static Tekton Stands (Exactly the 3x3 area)
if enhanced_gridmap:
for stand in get_tree().get_nodes_in_group("StaticTektonStands"):
var local_pos = enhanced_gridmap.to_local(stand.global_position)
var stand_map_pos = enhanced_gridmap.local_to_map(local_pos)
if abs(pos.x - stand_map_pos.x) <= 2 and abs(pos.y - stand_map_pos.z) <= 2:
if abs(pos.x - stand_map_pos.x) <= 1 and abs(pos.y - stand_map_pos.z) <= 1:
return true
var main_node = get_tree().get_root().get_node_or_null("Main")
if main_node and "reserved_static_positions" in main_node:
for reserved in main_node.reserved_static_positions:
if abs(pos.x - reserved.x) <= 2 and abs(pos.y - reserved.y) <= 2:
if abs(pos.x - reserved.x) <= 1 and abs(pos.y - reserved.y) <= 1:
return true
return false
+2
View File
@@ -167,6 +167,8 @@ transform = Transform3D(1.2, 0, 0, 0, -5.2453668e-08, -1.2, 0, 1.2, -5.2453668e-
visible = false
sprite_frames = ExtResource("10_y4r1p")
animation = &"floor_spawn_bot"
frame = 35
frame_progress = 1.0
[node name="receiver_skill_stunned" type="AnimatedSprite3D" parent="." unique_id=56953581]
transform = Transform3D(0.5, 0, 0, 0, -2.1855694e-08, -0.5, 0, 0.5, -2.1855694e-08, 0, 1.5653763, 0)