Skip to content

Commit

Permalink
adding dynamic lighting/shadows effects
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlac committed Oct 1, 2023
1 parent 93cf81a commit 787d52a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
23 changes: 22 additions & 1 deletion project/scenes/characters/player.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
[gd_scene load_steps=2 format=3 uid="uid://nuqlrvw8di7s"]
[gd_scene load_steps=4 format=3 uid="uid://nuqlrvw8di7s"]

[ext_resource type="Texture2D" uid="uid://dlxldnu52cpnv" path="res://assets/art/topdown/shooter/man_blue/manblue_gun.png" id="1_ts0vk"]

[sub_resource type="Gradient" id="Gradient_l415w"]
offsets = PackedFloat32Array(0, 0.773179)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)

[sub_resource type="GradientTexture2D" id="GradientTexture2D_b48d1"]
gradient = SubResource("Gradient_l415w")
fill = 1
fill_from = Vector2(0.5, 0.5)

[node name="Player" type="Character"]
scale = Vector2(2, 2)
collision_mask = 8
Expand All @@ -18,3 +27,15 @@ texture = ExtResource("1_ts0vk")
[node name="FiringPoint" type="Marker2D" parent="PlayerCollisionPoly"]
unique_name_in_owner = true
position = Vector2(23.5, 9.50009)

[node name="PointLight2D" type="PointLight2D" parent="."]
scale = Vector2(25, 25)
color = Color(0.839216, 0.913725, 0.898039, 1)
range_z_min = 0
range_z_max = 1000
range_layer_max = 100
shadow_enabled = true
shadow_color = Color(0, 0, 0, 0.937255)
shadow_filter = 2
texture = SubResource("GradientTexture2D_b48d1")
height = 100.0
35 changes: 32 additions & 3 deletions project/scenes/levels/level1.tscn
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
[gd_scene load_steps=6 format=3 uid="uid://c8tur70b73kih"]
[gd_scene load_steps=7 format=3 uid="uid://c8tur70b73kih"]

[ext_resource type="Texture2D" uid="uid://dsq2y3cfi6f0r" path="res://assets/art/prototype_textures/light/texture_03.png" id="1_nl15v"]
[ext_resource type="Texture2D" uid="uid://cl68k75es1iy3" path="res://assets/art/prototype_textures/dark/texture_04.png" id="2_6qqh6"]
[ext_resource type="Texture2D" uid="uid://b65xeiq7etdod" path="res://assets/art/prototype_textures/red/texture_02.png" id="3_blm5m"]
[ext_resource type="Texture2D" uid="uid://b4wu73uyjafmf" path="res://assets/art/prototype_textures/green/texture_10.png" id="4_ix12c"]
[ext_resource type="Texture2D" uid="uid://djiso2qx4vtt5" path="res://assets/art/prototype_textures/purple/texture_02.png" id="5_pmdlb"]

[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_d0buj"]
resource_local_to_scene = true
polygon = PackedVector2Array(512, -512, -512, -512, -512, 512, 512, 512)

[node name="Level1" type="Level"]

[node name="BackgroundTexture" type="Sprite2D" parent="."]
z_index = -100
show_behind_parent = true
scale = Vector2(4, 4)
texture = ExtResource("1_nl15v")

[node name="DirectionalLight2D" type="DirectionalLight2D" parent="."]
color = Color(1, 0.94902, 0.960784, 1)
energy = 0.75
blend_mode = 1
range_z_min = -100
range_z_max = 100
range_layer_max = 1
max_distance = 1000.0

[node name="Wall" type="StaticBody2D" parent="."]
z_index = 10
position = Vector2(400, 400)
Expand All @@ -26,8 +39,12 @@ polygon = PackedVector2Array(512, 512, -512, 512, -512, -512, 512, -512)
[node name="WallTexture" type="Sprite2D" parent="Wall"]
texture = ExtResource("2_6qqh6")

[node name="LightOccluder2D" type="LightOccluder2D" parent="Wall"]
occluder = SubResource("OccluderPolygon2D_d0buj")

[node name="DeathPit" type="StaticBody2D" parent="."]
z_index = -90
modulate = Color(0.207843, 0.0235294, 0, 1)
self_modulate = Color(0.0313726, 0.113725, 1, 1)
position = Vector2(-400, -400)
scale = Vector2(0.25, 0.25)
collision_layer = 32
Expand All @@ -37,8 +54,15 @@ collision_mask = 0
polygon = PackedVector2Array(512, 512, -512, 512, -512, -512, 512, -512)

[node name="DeathPitTexture" type="Sprite2D" parent="DeathPit"]
show_behind_parent = true
texture = ExtResource("3_blm5m")

[node name="LightOccluder2D" type="LightOccluder2D" parent="DeathPit"]
show_behind_parent = true
light_mask = 2
occluder = SubResource("OccluderPolygon2D_d0buj")
occluder_light_mask = 0

[node name="DamageZone" type="StaticBody2D" parent="."]
position = Vector2(-400, 400)
scale = Vector2(0.25, 0.25)
Expand Down Expand Up @@ -66,3 +90,8 @@ polygon = PackedVector2Array(512, 512, -512, 512, -512, -512, 512, -512)
[node name="PhysicsBoxTexture" type="Sprite2D" parent="PhysicsBox"]
scale = Vector2(0.25, 0.25)
texture = ExtResource("5_pmdlb")

[node name="LightOccluder2D" type="LightOccluder2D" parent="PhysicsBox"]
z_index = -1
scale = Vector2(0.25, 0.25)
occluder = SubResource("OccluderPolygon2D_d0buj")

0 comments on commit 787d52a

Please sign in to comment.