light_shadows.tscn 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. [gd_scene load_steps=25 format=3 uid="uid://xdjwv7eeck6l"]
  2. [ext_resource type="Texture2D" uid="uid://ulsh8ubvub37" path="res://background.png" id="1"]
  3. [ext_resource type="Script" path="res://light_shadows.gd" id="1_7xjm7"]
  4. [ext_resource type="Texture2D" uid="uid://kkvm5nl3vgun" path="res://caster.png" id="2"]
  5. [ext_resource type="Texture2D" uid="uid://dk6osr088g4l3" path="res://light.png" id="3"]
  6. [ext_resource type="Texture2D" uid="uid://cnyul1oe7d4b" path="res://spot.png" id="4"]
  7. [ext_resource type="Texture2D" uid="uid://bl3uv26bv8e38" path="res://godot.png" id="5"]
  8. [ext_resource type="Texture2D" uid="uid://qqnrpl3qn64k" path="res://godot_normal.png" id="6"]
  9. [sub_resource type="CanvasTexture" id="CanvasTexture_hlulo"]
  10. diffuse_texture = ExtResource("5")
  11. normal_texture = ExtResource("6")
  12. specular_shininess = 0.5
  13. [sub_resource type="CanvasTexture" id="CanvasTexture_hea5a"]
  14. diffuse_texture = ExtResource("5")
  15. normal_texture = ExtResource("6")
  16. specular_shininess = 0.5
  17. [sub_resource type="CanvasTexture" id="CanvasTexture_hc1ic"]
  18. diffuse_texture = ExtResource("5")
  19. normal_texture = ExtResource("6")
  20. specular_shininess = 0.5
  21. [sub_resource type="CanvasTexture" id="CanvasTexture_l1r6i"]
  22. diffuse_texture = ExtResource("5")
  23. normal_texture = ExtResource("6")
  24. specular_shininess = 0.5
  25. [sub_resource type="OccluderPolygon2D" id="1"]
  26. polygon = PackedVector2Array(-15.913, -15.9738, 15.9079, -16.0785, 15.6986, 15.847, -16.1223, 15.9517)
  27. [sub_resource type="CanvasItemMaterial" id="2"]
  28. blend_mode = 1
  29. [sub_resource type="Animation" id="3"]
  30. length = 16.0
  31. loop_mode = 1
  32. tracks/0/type = "value"
  33. tracks/0/imported = false
  34. tracks/0/enabled = true
  35. tracks/0/path = NodePath(".:position")
  36. tracks/0/interp = 1
  37. tracks/0/loop_wrap = true
  38. tracks/0/keys = {
  39. "times": PackedFloat32Array(0, 4, 8, 12),
  40. "transitions": PackedFloat32Array(-2, -2, -2, -2),
  41. "update": 0,
  42. "values": [Vector2(159.289, 452.441), Vector2(132.279, 80.4366), Vector2(700.722, 241.27), Vector2(429.392, 571.532)]
  43. }
  44. [sub_resource type="Animation" id="4"]
  45. length = 16.0
  46. loop_mode = 1
  47. tracks/0/type = "value"
  48. tracks/0/imported = false
  49. tracks/0/enabled = true
  50. tracks/0/path = NodePath(".:position")
  51. tracks/0/interp = 1
  52. tracks/0/loop_wrap = true
  53. tracks/0/keys = {
  54. "times": PackedFloat32Array(0, 4.1, 8.1, 11.8),
  55. "transitions": PackedFloat32Array(-2, -2, -2, -2),
  56. "update": 0,
  57. "values": [Vector2(753.756, 314.336), Vector2(69.7562, 234.336), Vector2(256.756, 575.336), Vector2(516.756, 530.336)]
  58. }
  59. [sub_resource type="AnimationLibrary" id="AnimationLibrary_wawvy"]
  60. _data = {
  61. "motion": SubResource("3"),
  62. "motion2": SubResource("4")
  63. }
  64. [sub_resource type="CanvasItemMaterial" id="5"]
  65. blend_mode = 1
  66. [sub_resource type="AnimationLibrary" id="AnimationLibrary_fig6v"]
  67. _data = {
  68. "m2": SubResource("4"),
  69. "motion": SubResource("3")
  70. }
  71. [sub_resource type="CanvasItemMaterial" id="6"]
  72. blend_mode = 1
  73. [sub_resource type="Animation" id="7"]
  74. length = 16.0
  75. loop_mode = 1
  76. tracks/0/type = "value"
  77. tracks/0/imported = false
  78. tracks/0/enabled = true
  79. tracks/0/path = NodePath(".:position")
  80. tracks/0/interp = 1
  81. tracks/0/loop_wrap = true
  82. tracks/0/keys = {
  83. "times": PackedFloat32Array(0, 4.1, 7.9, 12.1),
  84. "transitions": PackedFloat32Array(-2, -2, -2, -2),
  85. "update": 0,
  86. "values": [Vector2(692.078, 29.8849), Vector2(309.606, 31.5551), Vector2(40.7064, 238.658), Vector2(685.397, 282.082)]
  87. }
  88. [sub_resource type="AnimationLibrary" id="AnimationLibrary_kfxj1"]
  89. _data = {
  90. "motion": SubResource("3"),
  91. "motion2": SubResource("4"),
  92. "motion3": SubResource("7")
  93. }
  94. [sub_resource type="Animation" id="Animation_rgbru"]
  95. resource_name = "rotate_directional_light"
  96. length = 20.0
  97. loop_mode = 1
  98. tracks/0/type = "value"
  99. tracks/0/imported = false
  100. tracks/0/enabled = true
  101. tracks/0/path = NodePath("DirectionalLight2D:rotation")
  102. tracks/0/interp = 1
  103. tracks/0/loop_wrap = true
  104. tracks/0/keys = {
  105. "times": PackedFloat32Array(0, 20),
  106. "transitions": PackedFloat32Array(1, 1),
  107. "update": 0,
  108. "values": [0.0, 6.28319]
  109. }
  110. [sub_resource type="Animation" id="Animation_emv7u"]
  111. length = 0.001
  112. tracks/0/type = "value"
  113. tracks/0/imported = false
  114. tracks/0/enabled = true
  115. tracks/0/path = NodePath("DirectionalLight2D:rotation")
  116. tracks/0/interp = 1
  117. tracks/0/loop_wrap = true
  118. tracks/0/keys = {
  119. "times": PackedFloat32Array(0),
  120. "transitions": PackedFloat32Array(1),
  121. "update": 0,
  122. "values": [0.0]
  123. }
  124. [sub_resource type="AnimationLibrary" id="AnimationLibrary_6bket"]
  125. _data = {
  126. "RESET": SubResource("Animation_emv7u"),
  127. "rotate_directional_light": SubResource("Animation_rgbru")
  128. }
  129. [node name="LightShadows" type="Node2D"]
  130. script = ExtResource("1_7xjm7")
  131. [node name="Ambient" type="CanvasModulate" parent="."]
  132. color = Color(0.27451, 0.27451, 0.27451, 1)
  133. [node name="Background" type="Sprite2D" parent="."]
  134. position = Vector2(401.251, 302.906)
  135. scale = Vector2(128, 128)
  136. texture = ExtResource("1")
  137. [node name="Sprite2D" type="Sprite2D" parent="."]
  138. position = Vector2(295.886, 216.938)
  139. texture = SubResource("CanvasTexture_hlulo")
  140. [node name="Label" type="Label" parent="Sprite2D"]
  141. offset_left = -22.5563
  142. offset_top = 64.6982
  143. offset_right = 24.4437
  144. offset_bottom = 78.6982
  145. text = "Normal"
  146. [node name="SpriteFlipX" type="Sprite2D" parent="."]
  147. position = Vector2(543.341, 220.255)
  148. scale = Vector2(-1, 1)
  149. texture = SubResource("CanvasTexture_hea5a")
  150. [node name="Label" type="Label" parent="SpriteFlipX"]
  151. offset_left = 22.5564
  152. offset_top = 66.0347
  153. offset_right = 69.5564
  154. offset_bottom = 80.0347
  155. scale = Vector2(-1, 1)
  156. text = "Flip X"
  157. [node name="SpriteFlipY" type="Sprite2D" parent="."]
  158. position = Vector2(291.308, 423.369)
  159. scale = Vector2(1, -1)
  160. texture = SubResource("CanvasTexture_hc1ic")
  161. [node name="Label" type="Label" parent="SpriteFlipY"]
  162. offset_left = -23.3056
  163. offset_top = -67.2446
  164. offset_right = 23.6944
  165. offset_bottom = -53.2446
  166. scale = Vector2(1, -1)
  167. text = "Flip Y"
  168. [node name="SpriteFlipXY" type="Sprite2D" parent="."]
  169. position = Vector2(542.081, 424.696)
  170. scale = Vector2(-1, -1)
  171. texture = SubResource("CanvasTexture_l1r6i")
  172. [node name="Label" type="Label" parent="SpriteFlipXY"]
  173. offset_left = 23.9495
  174. offset_top = -67.5714
  175. offset_right = 81.9495
  176. offset_bottom = -53.5714
  177. scale = Vector2(-1, -1)
  178. text = "Flip X + Y"
  179. [node name="Casters" type="Node2D" parent="."]
  180. [node name="ShadowCaster" type="Sprite2D" parent="Casters"]
  181. position = Vector2(95.2909, 85.3186)
  182. texture = ExtResource("2")
  183. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster"]
  184. occluder = SubResource("1")
  185. [node name="ShadowCaster1" type="Sprite2D" parent="Casters"]
  186. position = Vector2(200.291, 313.319)
  187. texture = ExtResource("2")
  188. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster1"]
  189. occluder = SubResource("1")
  190. [node name="ShadowCaster2" type="Sprite2D" parent="Casters"]
  191. position = Vector2(76.2909, 405.319)
  192. texture = ExtResource("2")
  193. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster2"]
  194. occluder = SubResource("1")
  195. [node name="ShadowCaster3" type="Sprite2D" parent="Casters"]
  196. position = Vector2(408.291, 226.319)
  197. texture = ExtResource("2")
  198. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster3"]
  199. occluder = SubResource("1")
  200. [node name="ShadowCaster4" type="Sprite2D" parent="Casters"]
  201. position = Vector2(239.291, 48.3186)
  202. texture = ExtResource("2")
  203. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster4"]
  204. occluder = SubResource("1")
  205. [node name="ShadowCaster5" type="Sprite2D" parent="Casters"]
  206. position = Vector2(140.291, 561.319)
  207. texture = ExtResource("2")
  208. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster5"]
  209. occluder = SubResource("1")
  210. [node name="ShadowCaster6" type="Sprite2D" parent="Casters"]
  211. position = Vector2(392.291, 499.319)
  212. texture = ExtResource("2")
  213. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster6"]
  214. occluder = SubResource("1")
  215. [node name="ShadowCaster7" type="Sprite2D" parent="Casters"]
  216. position = Vector2(735.291, 552.319)
  217. texture = ExtResource("2")
  218. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster7"]
  219. occluder = SubResource("1")
  220. [node name="ShadowCaster8" type="Sprite2D" parent="Casters"]
  221. position = Vector2(661.291, 371.319)
  222. texture = ExtResource("2")
  223. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster8"]
  224. occluder = SubResource("1")
  225. [node name="ShadowCaster9" type="Sprite2D" parent="Casters"]
  226. position = Vector2(567.291, 574.319)
  227. texture = ExtResource("2")
  228. [node name="occluder" type="LightOccluder2D" parent="Casters/ShadowCaster9"]
  229. occluder = SubResource("1")
  230. [node name="ShadowCaster10" type="Sprite2D" parent="Casters"]
  231. position = Vector2(420.291, 350.319)
  232. texture = ExtResource("2")
  233. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster10"]
  234. occluder = SubResource("1")
  235. [node name="ShadowCaster11" type="Sprite2D" parent="Casters"]
  236. position = Vector2(463.291, 106.319)
  237. texture = ExtResource("2")
  238. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster11"]
  239. occluder = SubResource("1")
  240. [node name="ShadowCaster12" type="Sprite2D" parent="Casters"]
  241. position = Vector2(621.291, 78.3186)
  242. texture = ExtResource("2")
  243. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster12"]
  244. occluder = SubResource("1")
  245. [node name="ShadowCaster13" type="Sprite2D" parent="Casters"]
  246. position = Vector2(761.291, 240.319)
  247. texture = ExtResource("2")
  248. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster13"]
  249. occluder = SubResource("1")
  250. [node name="ShadowCaster14" type="Sprite2D" parent="Casters"]
  251. position = Vector2(771.291, 29.3186)
  252. texture = ExtResource("2")
  253. [node name="Occluder" type="LightOccluder2D" parent="Casters/ShadowCaster14"]
  254. occluder = SubResource("1")
  255. [node name="RedLight" type="PointLight2D" parent="." groups=["point_light"]]
  256. position = Vector2(159.289, 452.441)
  257. color = Color(1, 0.446392, 0.0576646, 1)
  258. shadow_enabled = true
  259. shadow_filter = 1
  260. shadow_filter_smooth = 1.2
  261. texture = ExtResource("3")
  262. [node name="Blob" type="Sprite2D" parent="RedLight"]
  263. material = SubResource("2")
  264. texture = ExtResource("4")
  265. [node name="AnimationPlayer" type="AnimationPlayer" parent="RedLight"]
  266. autoplay = "motion"
  267. libraries = {
  268. "": SubResource("AnimationLibrary_wawvy")
  269. }
  270. [node name="GreenLight" type="PointLight2D" parent="." groups=["point_light"]]
  271. position = Vector2(753.756, 314.336)
  272. color = Color(0.49247, 0.878537, 0.409146, 1)
  273. shadow_enabled = true
  274. shadow_filter = 1
  275. shadow_filter_smooth = 1.2
  276. texture = ExtResource("3")
  277. [node name="blob" type="Sprite2D" parent="GreenLight"]
  278. material = SubResource("5")
  279. texture = ExtResource("4")
  280. [node name="AnimationPlayer" type="AnimationPlayer" parent="GreenLight"]
  281. autoplay = "m2"
  282. libraries = {
  283. "": SubResource("AnimationLibrary_fig6v")
  284. }
  285. [node name="BlueLight" type="PointLight2D" parent="." groups=["point_light"]]
  286. position = Vector2(692.078, 29.8849)
  287. color = Color(0.396752, 0.446392, 0.929792, 1)
  288. shadow_enabled = true
  289. shadow_filter = 1
  290. shadow_filter_smooth = 1.2
  291. texture = ExtResource("3")
  292. [node name="blob" type="Sprite2D" parent="BlueLight"]
  293. material = SubResource("6")
  294. texture = ExtResource("4")
  295. [node name="AnimationPlayer" type="AnimationPlayer" parent="BlueLight"]
  296. autoplay = "motion3"
  297. libraries = {
  298. "": SubResource("AnimationLibrary_kfxj1")
  299. }
  300. [node name="Camera2D" type="Camera2D" parent="."]
  301. offset = Vector2(400, 300)
  302. current = true
  303. [node name="CanvasLayer" type="CanvasLayer" parent="."]
  304. [node name="Label" type="Label" parent="CanvasLayer"]
  305. anchors_preset = 2
  306. anchor_top = 1.0
  307. anchor_bottom = 1.0
  308. offset_left = 16.0
  309. offset_top = -120.0
  310. offset_right = 321.0
  311. offset_bottom = -1.0
  312. grow_vertical = 0
  313. theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
  314. theme_override_constants/outline_size = 4
  315. text = "D: Toggle directional light
  316. P: Toggle point lights
  317. S: Cycle directional light shadow quality
  318. H: Cycle point light shadow quality"
  319. [node name="DirectionalLight2D" type="DirectionalLight2D" parent="."]
  320. visible = false
  321. shadow_enabled = true
  322. shadow_filter = 1
  323. shadow_filter_smooth = 1.2
  324. [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
  325. autoplay = "rotate_directional_light"
  326. libraries = {
  327. "": SubResource("AnimationLibrary_6bket")
  328. }