1
0
Fork 0

Nebula background

This commit is contained in:
Fabio Iotti 2024-08-10 08:54:21 +02:00
parent f4d271a6cc
commit fb97d172f4
Signed by: bruce965
GPG key ID: 4EC13D9158A96B4C
3 changed files with 42 additions and 1 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://cdaf4bh0jaa45"] [gd_scene load_steps=12 format=3 uid="uid://cdaf4bh0jaa45"]
[ext_resource type="PackedScene" uid="uid://dq00mi6jwsa1f" path="res://scenes/planet/planet.tscn" id="1_0p552"] [ext_resource type="PackedScene" uid="uid://dq00mi6jwsa1f" path="res://scenes/planet/planet.tscn" id="1_0p552"]
[ext_resource type="Script" path="res://scripts/game_logic.gd" id="1_kb05v"] [ext_resource type="Script" path="res://scripts/game_logic.gd" id="1_kb05v"]
@ -8,6 +8,7 @@
[ext_resource type="Script" path="res://scenes/player/local_player.gd" id="4_7rlmh"] [ext_resource type="Script" path="res://scenes/player/local_player.gd" id="4_7rlmh"]
[ext_resource type="Texture2D" uid="uid://dx1wjviioa8u5" path="res://icons/chip.svg" id="4_pgo63"] [ext_resource type="Texture2D" uid="uid://dx1wjviioa8u5" path="res://icons/chip.svg" id="4_pgo63"]
[ext_resource type="Script" path="res://ui.gd" id="7_khbdl"] [ext_resource type="Script" path="res://ui.gd" id="7_khbdl"]
[ext_resource type="PackedScene" uid="uid://dtlatmtuggp6x" path="res://scenes/nebula/nebula.tscn" id="7_sv4lv"]
[ext_resource type="PackedScene" uid="uid://cpffyaoh8x5bp" path="res://scenes/ships_fleet/ships_fleet.tscn" id="9_be18b"] [ext_resource type="PackedScene" uid="uid://cpffyaoh8x5bp" path="res://scenes/ships_fleet/ships_fleet.tscn" id="9_be18b"]
[ext_resource type="PackedScene" uid="uid://ckfk1xgxfk1c3" path="res://scenes/trail/trail.tscn" id="10_b5ql7"] [ext_resource type="PackedScene" uid="uid://ckfk1xgxfk1c3" path="res://scenes/trail/trail.tscn" id="10_b5ql7"]
@ -37,6 +38,8 @@ script = ExtResource("2_plgh6")
color = Color(0.835294, 0.160784, 0, 1) color = Color(0.835294, 0.160784, 0, 1)
icon = ExtResource("4_pgo63") icon = ExtResource("4_pgo63")
[node name="Nebula" parent="." instance=ExtResource("7_sv4lv")]
[node name="Game" type="Node2D" parent="."] [node name="Game" type="Node2D" parent="."]
[node name="Planets" type="Node2D" parent="Game"] [node name="Planets" type="Node2D" parent="Game"]

View file

@ -0,0 +1,14 @@
shader_type canvas_item;
uniform sampler2D noise: repeat_enable;
float rand(vec2 co){
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
}
void fragment() {
vec3 nebula = vec3(texture(noise, FRAGCOORD.xy * .0005).r, texture(noise, FRAGCOORD.xy * .0005 + 0.1).r, texture(noise, FRAGCOORD.xy * .0005 + 0.2).r) * 0.05;
vec3 star = (rand(FRAGCOORD.xy * .01) < 0.1 && rand(FRAGCOORD.xy * .02) < .01) ? vec3(rand(FRAGCOORD.xy * .03)) : vec3(0.);
COLOR = vec4(nebula + star, 1.);
}

24
scenes/nebula/nebula.tscn Normal file
View file

@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://dtlatmtuggp6x"]
[ext_resource type="Shader" path="res://scenes/nebula/nebula.gdshader" id="1_nqp0c"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_8c2xm"]
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_cukca"]
width = 256
height = 256
seamless = true
noise = SubResource("FastNoiseLite_8c2xm")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_y72ex"]
shader = ExtResource("1_nqp0c")
shader_parameter/noise = SubResource("NoiseTexture2D_cukca")
[node name="Nebula" type="ColorRect"]
material = SubResource("ShaderMaterial_y72ex")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2