[gd_scene load_steps=12 format=2] [ext_resource path="res://Assets/topdown-player.svg" type="Texture" id=1] [ext_resource path="res://Demos/StarFieldDemo.tscn" type="PackedScene" id=2] [ext_resource path="res://GhostTrail/GhostTrail.tscn" type="PackedScene" id=3] [sub_resource type="GDScript" id=1] script/source = "extends Camera2D export(float) var speed = 0 func _process(delta): translate((Vector2.RIGHT * speed) * delta) " [sub_resource type="Shader" id=2] code = "shader_type canvas_item; const float SAMPLES = 71.0; const float WIDTH = 0.04734573810584494679397346954847; //1.0 / sqrt(PI * 2 * SAMPLES) uniform vec2 blur_scale = vec2(1, 0); float gaussian(float x) { float x_squared = x*x; return WIDTH * exp((x_squared / (2.0 * SAMPLES)) * -1.0); } void fragment() { vec2 scale = TEXTURE_PIXEL_SIZE * blur_scale; float weight = 0.0; float total_weight = 0.0; vec4 color = vec4(0.0); for(int i=-int(SAMPLES)/2; i < int(SAMPLES)/2; ++i) { weight = gaussian(float(i)); color.rgb += texture(TEXTURE, UV + scale * vec2(float(i))).rgb * weight; total_weight += weight; } COLOR.rgb = color.rgb / total_weight; }" [sub_resource type="ShaderMaterial" id=3] shader = SubResource( 2 ) shader_param/blur_scale = Vector2( 0, 0 ) [sub_resource type="ViewportTexture" id=4] viewport_path = NodePath("Viewport") [sub_resource type="Gradient" id=5] colors = PoolColorArray( 1, 1, 1, 0.435294, 1, 1, 1, 0 ) [sub_resource type="GradientTexture" id=6] gradient = SubResource( 5 ) [sub_resource type="ParticlesMaterial" id=7] flag_align_y = true flag_rotate_y = true flag_disable_z = true direction = Vector3( 0, -1, 0 ) spread = 0.0 gravity = Vector3( 0, 0, 0 ) initial_velocity = 1.0 orbit_velocity = 0.0 orbit_velocity_random = 0.0 scale = 0.7 color_ramp = SubResource( 6 ) [sub_resource type="Animation" id=8] length = 6.0 loop = true step = 0.05 tracks/0/type = "value" tracks/0/path = NodePath("Viewport/Camera2D:speed") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { "times": PoolRealArray( 0, 1.6, 2.25, 4 ), "transitions": PoolRealArray( 1, 2, 1, 2 ), "update": 0, "values": [ 200.0, 200.0, 2000.0, 4000.0 ] } tracks/1/type = "value" tracks/1/path = NodePath("BlurHorizontal:material:shader_param/blur_scale") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true tracks/1/keys = { "times": PoolRealArray( 0, 1.6, 2.25, 4 ), "transitions": PoolRealArray( 1, 2, 1, 2 ), "update": 0, "values": [ Vector2( 0, 0 ), Vector2( 0, 0 ), Vector2( 4, 0 ), Vector2( 6, 0 ) ] } tracks/2/type = "value" tracks/2/path = NodePath("Sprite/GhostTrail:emitting") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/imported = false tracks/2/enabled = true tracks/2/keys = { "times": PoolRealArray( 0, 1.6, 5.5 ), "transitions": PoolRealArray( 1, 1, 1 ), "update": 1, "values": [ false, true, false ] } tracks/3/type = "value" tracks/3/path = NodePath("Sprite/GhostTrail:speed_scale") tracks/3/interp = 1 tracks/3/loop_wrap = true tracks/3/imported = false tracks/3/enabled = true tracks/3/keys = { "times": PoolRealArray( 0, 1.6, 2.25, 4 ), "transitions": PoolRealArray( 2, 2, 1, 2 ), "update": 0, "values": [ 0.2, 0.2, 1.0, 4.0 ] } tracks/4/type = "value" tracks/4/path = NodePath("Sprite/GhostTrail:process_material:initial_velocity") tracks/4/interp = 1 tracks/4/loop_wrap = true tracks/4/imported = false tracks/4/enabled = true tracks/4/keys = { "times": PoolRealArray( 0, 1.6, 2.25 ), "transitions": PoolRealArray( 1, 1, 1 ), "update": 0, "values": [ 1.0, 1.0, 500.0 ] } [node name="BlurTest" type="Node"] [node name="Viewport" type="Viewport" parent="."] size = Vector2( 1024, 600 ) render_target_v_flip = true [node name="StarFieldTest" parent="Viewport" instance=ExtResource( 2 )] [node name="Camera2D" type="Camera2D" parent="Viewport"] anchor_mode = 0 current = true script = SubResource( 1 ) speed = 200.0 [node name="BlurHorizontal" type="TextureRect" parent="."] material = SubResource( 3 ) anchor_right = 1.0 anchor_bottom = 1.0 texture = SubResource( 4 ) __meta__ = { "_edit_use_anchors_": false } [node name="Sprite" type="Sprite" parent="."] position = Vector2( 473.5, 312.5 ) rotation = 1.5708 scale = Vector2( 0.7, 0.7 ) texture = ExtResource( 1 ) [node name="GhostTrail" parent="Sprite" instance=ExtResource( 3 )] emitting = false speed_scale = 0.2 process_material = SubResource( 7 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "Accelerate" anims/Accelerate = SubResource( 8 )