Skip to content

Commit 0980afd

Browse files
committed
feat: better looking stuff
1 parent d67db9c commit 0980afd

File tree

8 files changed

+270
-129
lines changed

8 files changed

+270
-129
lines changed

godot/art/images/ground.jpg

182 KB
Loading

godot/art/images/ground.jpg.import

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://c3n5rcebnmr3h"
6+
path.s3tc="res://.godot/imported/ground.jpg-517caef4875e51c08ef16ba8e1e1a31c.s3tc.ctex"
7+
metadata={
8+
"imported_formats": ["s3tc_bptc"],
9+
"vram_texture": true
10+
}
11+
12+
[deps]
13+
14+
source_file="res://art/images/ground.jpg"
15+
dest_files=["res://.godot/imported/ground.jpg-517caef4875e51c08ef16ba8e1e1a31c.s3tc.ctex"]
16+
17+
[params]
18+
19+
compress/mode=2
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=true
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=0

godot/scenes/CRT.gdshader

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ uniform float bloom_intensity : hint_range(0.0, 1.0) = 0.25;
4040
uniform float bloom_threshold : hint_range(0.0, 2.0) = 1.0; // >1 = only very bright
4141
uniform float bloom_radius_px : hint_range(0.0, 8.0) = 2.0;
4242
uniform vec4 corner_bg_color : source_color = vec4(0.0745098, 0.0745098, 0.09411765, 1.0);
43+
uniform float saturation : hint_range(0.0, 2.0) = 1.0; // Saturation control
4344

4445
float FIXF(float c) { return max(abs(c), 1e-5); }
4546
vec4 FIX4(vec4 c) { return max(abs(c), vec4(1e-5)); }
@@ -275,6 +276,10 @@ void fragment() {
275276
// Blend content with corner background (already linear due to source_color)
276277
vec3 rgb = mix(corner_bg_color.rgb, content_rgb, cval);
277278

279+
// Apply saturation
280+
vec3 grayscale = vec3(dot(rgb, vec3(0.299, 0.587, 0.114)));
281+
rgb = mix(grayscale, rgb, saturation);
282+
278283
// Output in linear space; Godot handles display gamma conversion
279284
COLOR = vec4(rgb, 1.0);
280285
}

godot/scenes/Main.tscn

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=14 format=3 uid="uid://dmow5ogajbtl5"]
1+
[gd_scene load_steps=15 format=3 uid="uid://dmow5ogajbtl5"]
22

33
[ext_resource type="PackedScene" uid="uid://d1he7h6c2ifoi" path="res://scenes/Ship/Ship.tscn" id="1_5j0jt"]
44
[ext_resource type="Script" uid="uid://d1hcgilyrpu7d" path="res://scenes/main.gd" id="1_24mpf"]
@@ -26,9 +26,11 @@ ssao_enabled = true
2626
sdfgi_read_sky_light = false
2727
glow_enabled = true
2828

29+
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_q8u5g"]
30+
2931
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lhr70"]
3032
shader = ExtResource("9_q8u5g")
31-
shader_parameter/CRTgamma = 2.16
33+
shader_parameter/CRTgamma = 2.4
3234
shader_parameter/monitorgamma = 2.2
3335
shader_parameter/d = 3.0
3436
shader_parameter/CURVATURE = 1.0
@@ -39,10 +41,10 @@ shader_parameter/x_tilt = 0.0
3941
shader_parameter/y_tilt = 0.0
4042
shader_parameter/overscan_x = 95.0
4143
shader_parameter/overscan_y = 95.0
42-
shader_parameter/DOTMASK = 0.229
43-
shader_parameter/SHARPER = 1.0
44+
shader_parameter/DOTMASK = 0.173
45+
shader_parameter/SHARPER = 1.375
4446
shader_parameter/scanline_weight = 0.249
45-
shader_parameter/lum = 0.581
47+
shader_parameter/lum = 0.76
4648
shader_parameter/enable_480i = false
4749
shader_parameter/interlace_offset = 1.0
4850
shader_parameter/clamp_resolution = true
@@ -55,6 +57,7 @@ shader_parameter/bloom_intensity = 0.136
5557
shader_parameter/bloom_threshold = 0.219
5658
shader_parameter/bloom_radius_px = 0.175
5759
shader_parameter/corner_bg_color = Color(0.0745098, 0.0745098, 0.0941176, 1)
60+
shader_parameter/saturation = 0.5
5861

5962
[node name="Main" type="Node3D" node_paths=PackedStringArray("planet") groups=["affected_by_gravity"]]
6063
script = ExtResource("1_24mpf")
@@ -76,9 +79,29 @@ zoom_sensitivity = 1.0
7679
max_zoom = 100.0
7780

7881
[node name="Planet" parent="." instance=ExtResource("4_hrnxs")]
79-
transform = Transform3D(0.428786, 0, 0.903406, 0, 1, 0, -0.903406, 0, 0.428786, 0, 0, 0)
82+
transform = Transform3D(-0.84147, 0, 0.540303, 0, 1, 0, -0.540303, 0, -0.84147, 0, 0, 0)
83+
physics_material_override = SubResource("PhysicsMaterial_q8u5g")
84+
constant_angular_velocity = Vector3(0, 0.005, 0)
85+
regenerate_in_editor = null
8086
radius = 5000.0
87+
micro_octaves = 4
88+
micro_lacunarity = 10.0
89+
micro_gain = 3.0
90+
micro_strength = 0.05
91+
flatten_deadband = 0.2
92+
range_anisotropy = 0.3
93+
ice_cap_latitude_start = 0.95
94+
ice_cap_latitude_full = 0.96
95+
ice_cap_height_bias = 0.35
96+
smooth_lambda = 0.0
8197
gravitational_pull = 5e+07
98+
atmosphere_height_scale = 1.0
99+
atmosphere_intensity = 0.0
100+
atmosphere_mie_intensity = 0.0
101+
atmosphere_g = 0.2
102+
atmosphere_color = Color(1, 0.507, 0.13, 1)
103+
atmosphere_mie_color = Color(0.800191, 0, 0.311489, 1)
104+
use_mesh_atmosphere = false
82105

83106
[node name="Sun" parent="." instance=ExtResource("7_nxtc6")]
84107
transform = Transform3D(1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 2e+06, 2e+06, 2e+06)

godot/scenes/Planet/Planet.gd

Lines changed: 77 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1+
@tool
12
extends Node3D
23

34
@onready var mesh_instance = $MeshInstance3D
45
@onready var collision_shape_instance = $CollisionShape3D
56

7+
@export var regenerate_in_editor: bool = false: set = _regenerate_in_editor_button
8+
9+
@export_group("Dimensions")
610
@export var radius: float = 200000.0
7-
@export var rotation_speed: float = 0.005
8-
@export var gravitational_pull: float = 3e9
911
@export var segments: int = 128
10-
11-
# Terrain noise controls
12+
@export_group("Terrain Noise")
1213
@export var relief_scale: float = 0.06
14+
@export_group("Base Noise")
1315
@export var base_frequency: float = 0.08
1416
@export var base_octaves: int = 4
1517
@export var base_lacunarity: float = 2.0
1618
@export var base_gain: float = 0.45
19+
@export_group("Detail Noise")
1720
@export var detail_frequency: float = 2.5
1821
@export var detail_octaves: int = 4
1922
@export var detail_lacunarity: float = 2.2
2023
@export var detail_gain: float = 0.48
24+
@export_group("Micro Noise")
2125
@export var micro_frequency: float = 6.0
2226
@export var micro_octaves: int = 3
2327
@export var micro_lacunarity: float = 2.4
2428
@export var micro_gain: float = 0.52
2529
@export var micro_strength: float = 0.25
26-
27-
# Terrain flattening controls (flatten small variations into broader flats)
30+
@export_group("Feature Shaping")
2831
@export var flatten_deadband: float = 0.15
29-
30-
# Feature shaping controls
3132
@export var terrace_steps: int = 7
3233
@export var terrace_strength: float = 3
3334
@export var range_strength: float = 0.35
3435
@export var range_frequency_main: float = 1.6
3536
@export var range_anisotropy: float = 0.2
3637
@export var range_rotation_deg: float = 47.0
37-
38-
# Polar ice cap controls
39-
@export var ice_cap_latitude_start: float = 0.95 # Latitude where the transition to ice caps begins
40-
@export var ice_cap_latitude_full: float = 0.96 # Latitude where the transition to ice caps is complete
41-
@export var ice_cap_height_bias: float = 0.35 # Raised height of the final ice cap, relative to relief_scale
42-
43-
# Mesh smoothing/triangulation controls
38+
@export_group("Polar Ice Caps")
39+
@export var ice_cap_latitude_start: float = 0.82 # Latitude where the transition to ice caps begins
40+
@export var ice_cap_latitude_full: float = 0.86 # Latitude where the transition to ice caps is complete
41+
@export var ice_cap_height_bias: float = 0.25 # Raised height of the final ice cap, relative to relief_scale
42+
@export_group("Mesh Quality")
4443
@export var smooth_iterations: int = 0
4544
@export var smooth_lambda: float = 0.5
4645
@export var alternate_quad_diagonals: bool = true
47-
48-
# Performance controls
46+
@export_group("Performance")
4947
@export var use_threaded_generation: bool = false
5048
@export var generation_chunk_size: int = 8
51-
52-
# Atmosphere controls
49+
@export_group("Physics")
50+
@export var rotation_speed: float = 0.005
51+
@export var gravitational_pull: float = 3e9
52+
@export_group("Atmosphere")
5353
@export var atmosphere_height_scale: float = 0.4 # fraction of radius
5454
@export var atmosphere_intensity: float = 0.5
5555
@export var atmosphere_mie_intensity: float = 0.3
@@ -58,8 +58,7 @@ extends Node3D
5858
@export var atmosphere_mie_color: Color = Color(1.0, 0.95, 0.9)
5959
@export var atmosphere_segments: int = 32
6060
@export var use_mesh_atmosphere: bool = true
61-
62-
# Scatter (pebbles/boulders) controls
61+
@export_group("Scatter")
6362
@export var enable_scatter: bool = true
6463
@export var scatter_radius: float = 800.0
6564
@export var scatter_rebuild_move_deg: float = 2.0
@@ -76,6 +75,7 @@ extends Node3D
7675
@export var scatter_color_boulder: Color = Color(0.26, 0.18, 0.14)
7776
@export var scatter_draw_distance: float = 8000.0
7877
@export var scatter_update_interval: float = 0.25
78+
@export_group("") # End groups
7979

8080
var noise: FastNoiseLite = FastNoiseLite.new() # detail
8181
var noise_base: FastNoiseLite = FastNoiseLite.new()
@@ -111,29 +111,7 @@ var atmosphere_material: ShaderMaterial
111111

112112
func _ready() -> void:
113113
# Configure noise
114-
noise.seed = randi()
115-
noise.noise_type = FastNoiseLite.TYPE_PERLIN
116-
noise.fractal_type = FastNoiseLite.FRACTAL_FBM
117-
noise.frequency = detail_frequency
118-
noise.fractal_octaves = detail_octaves
119-
noise.fractal_lacunarity = detail_lacunarity
120-
noise.fractal_gain = detail_gain
121-
122-
noise_base.seed = randi() + 1337
123-
noise_base.noise_type = FastNoiseLite.TYPE_PERLIN
124-
noise_base.fractal_type = FastNoiseLite.FRACTAL_RIDGED
125-
noise_base.frequency = base_frequency
126-
noise_base.fractal_octaves = base_octaves
127-
noise_base.fractal_lacunarity = base_lacunarity
128-
noise_base.fractal_gain = base_gain
129-
130-
noise_micro.seed = randi() + 4242
131-
noise_micro.noise_type = FastNoiseLite.TYPE_SIMPLEX
132-
noise_micro.fractal_type = FastNoiseLite.FRACTAL_FBM
133-
noise_micro.frequency = micro_frequency
134-
noise_micro.fractal_octaves = micro_octaves
135-
noise_micro.fractal_lacunarity = micro_lacunarity
136-
noise_micro.fractal_gain = micro_gain
114+
_configure_noise_instances()
137115

138116
# Cache a basis to orient mountain ranges (deterministic)
139117
var axis: Vector3 = Vector3(0.42, 0.86, 0.27).normalized()
@@ -535,6 +513,7 @@ func create_planet_material() -> ShaderMaterial:
535513
material.set_shader_parameter("planet_radius", radius)
536514
material.set_shader_parameter("detail_scale", 24.0)
537515
material.set_shader_parameter("detail_strength", 0.15)
516+
material.set_shader_parameter("ground_texture", load("res://art/images/ground.jpg"))
538517
material.set_shader_parameter("normal_strength", 0.0)
539518
material.set_shader_parameter("detail_fade_start", radius * 0.6)
540519
material.set_shader_parameter("detail_fade_end", radius * 3.0)
@@ -549,6 +528,17 @@ func create_planet_material() -> ShaderMaterial:
549528
material.set_shader_parameter("atmo_mie_color", atmosphere_mie_color)
550529
return material
551530

531+
func _process(_delta: float):
532+
# In the editor or at runtime, the separate atmosphere mesh needs continuous updates
533+
# to correctly calculate its appearance based on camera position. This will not
534+
# reintroduce shadow artifacts as the atmosphere mesh does not cast shadows.
535+
if use_mesh_atmosphere:
536+
if not is_instance_valid(atmosphere_material):
537+
return
538+
# Only update if the node is visible and in a viewport
539+
if is_visible_in_tree() and get_viewport():
540+
_update_atmosphere_params()
541+
552542
func _physics_process(delta: float) -> void:
553543
if not initialized:
554544
return
@@ -560,8 +550,11 @@ func _physics_process(delta: float) -> void:
560550
if is_instance_valid(landing_static_body):
561551
landing_static_body.constant_angular_velocity = Vector3(0.0, rotation_speed, 0.0)
562552

563-
# Disable continuous atmosphere updates to prevent rolling shadows
564-
# Atmosphere parameters will be set once at initialization
553+
# Atmosphere is a separate visual effect and must be updated each frame
554+
# to work correctly from different camera angles. It does not cast shadows,
555+
# so this will not reintroduce the rolling shadow artifacts on the surface.
556+
if use_mesh_atmosphere:
557+
_update_atmosphere_params()
565558

566559
# Apply gravitational pull only to bodies that aren't too far
567560
for body in get_tree().get_nodes_in_group("affected_by_gravity"):
@@ -984,3 +977,41 @@ func _generate_scatter_for_center(center_dir: Vector3) -> void:
984977
while idx_p < pebble_count:
985978
pebbles_mmi.multimesh.set_instance_transform(idx_p, Transform3D())
986979
idx_p += 1
980+
981+
# Setter functions for live parameter updates in editor
982+
func _regenerate_in_editor_button(_value: bool):
983+
if Engine.is_editor_hint():
984+
print("Regenerating planet in editor...")
985+
_configure_noise_instances()
986+
var axis: Vector3 = Vector3(0.42, 0.86, 0.27).normalized()
987+
range_basis = Basis(axis, deg_to_rad(range_rotation_deg))
988+
generate_planet()
989+
if use_mesh_atmosphere:
990+
_create_or_update_atmosphere()
991+
print("Regeneration complete.")
992+
993+
func _configure_noise_instances():
994+
# Configure noise
995+
noise.seed = randi()
996+
noise.noise_type = FastNoiseLite.TYPE_PERLIN
997+
noise.fractal_type = FastNoiseLite.FRACTAL_FBM
998+
noise.frequency = detail_frequency
999+
noise.fractal_octaves = detail_octaves
1000+
noise.fractal_lacunarity = detail_lacunarity
1001+
noise.fractal_gain = detail_gain
1002+
1003+
noise_base.seed = randi() + 1337
1004+
noise_base.noise_type = FastNoiseLite.TYPE_PERLIN
1005+
noise_base.fractal_type = FastNoiseLite.FRACTAL_RIDGED
1006+
noise_base.frequency = base_frequency
1007+
noise_base.fractal_octaves = base_octaves
1008+
noise_base.fractal_lacunarity = base_lacunarity
1009+
noise_base.fractal_gain = base_gain
1010+
1011+
noise_micro.seed = randi() + 4242
1012+
noise_micro.noise_type = FastNoiseLite.TYPE_SIMPLEX
1013+
noise_micro.fractal_type = FastNoiseLite.FRACTAL_FBM
1014+
noise_micro.frequency = micro_frequency
1015+
noise_micro.fractal_octaves = micro_octaves
1016+
noise_micro.fractal_lacunarity = micro_lacunarity
1017+
noise_micro.fractal_gain = micro_gain

godot/scenes/Planet/Planet.tscn

Lines changed: 49 additions & 19 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)