small racing game im working on
-rw-r--r--assets/mats/grass.tres3
-rw-r--r--assets/mats/proc_sky.tres7
-rw-r--r--assets/mats/road.tres9
-rw-r--r--assets/mats/shader_sky.tres90
-rw-r--r--assets/mats/sky.gdshader159
-rw-r--r--assets/mats/support.tres3
-rw-r--r--assets/textures/base-noise.pngbin0 -> 16213 bytes
-rw-r--r--assets/textures/base-noise.png.import36
-rw-r--r--assets/textures/grass.pngbin144 -> 96 bytes
-rw-r--r--assets/textures/support.pngbin97 -> 87 bytes
-rw-r--r--default_env.tres30
-rw-r--r--main.tscn41
-rw-r--r--scenes/track-base.gd21
-rw-r--r--scenes/track.tscn14
-rw-r--r--track.gd22
-rw-r--r--tracks/speedway_curve.tres1
-rw-r--r--tracks/speedway_track.tres3
-rw-r--r--ui/gears.gd10
-rw-r--r--ui/map.gd25
-rw-r--r--ui/revs.gd7
-rw-r--r--ui/speedometer.gd2
21 files changed, 391 insertions, 92 deletions
diff --git a/assets/mats/grass.tres b/assets/mats/grass.tres
index 92d7e82..0e63a35 100644
--- a/assets/mats/grass.tres
+++ b/assets/mats/grass.tres
@@ -1,4 +1,4 @@
-[gd_resource type="StandardMaterial3D" load_steps=2 format=3]
+[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bdyn312e6c3ll"]
[ext_resource type="Texture2D" uid="uid://dyk71hogwv01g" path="res://assets/textures/grass.png" id="1_2pspn"]
@@ -8,3 +8,4 @@ emission = Color(0, 0.0745098, 0.219608, 1)
emission_energy_multiplier = 16.0
ao_light_affect = 0.33
uv1_scale = Vector3(100, 100, 100)
+texture_filter = 0
diff --git a/assets/mats/proc_sky.tres b/assets/mats/proc_sky.tres
new file mode 100644
index 0000000..8076ff8
--- /dev/null
+++ b/assets/mats/proc_sky.tres
@@ -0,0 +1,7 @@
+[gd_resource type="ProceduralSkyMaterial" format=3 uid="uid://b8gjliaaeajp5"]
+
+[resource]
+sky_top_color = Color(0, 0.8, 1, 1)
+sky_horizon_color = Color(0.4, 1, 1, 1)
+ground_bottom_color = Color(0.4, 1, 1, 1)
+ground_horizon_color = Color(0.4, 1, 1, 1)
diff --git a/assets/mats/road.tres b/assets/mats/road.tres
new file mode 100644
index 0000000..85db5d5
--- /dev/null
+++ b/assets/mats/road.tres
@@ -0,0 +1,9 @@
+[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://be8pta62kxd2j"]
+
+[ext_resource type="Texture2D" uid="uid://2fjjxft1ip57" path="res://assets/textures/road.png" id="1_hqst8"]
+
+[resource]
+albedo_texture = ExtResource("1_hqst8")
+metallic_specular = 0.0
+uv1_scale = Vector3(8, 8, 8)
+texture_filter = 0
diff --git a/assets/mats/shader_sky.tres b/assets/mats/shader_sky.tres
new file mode 100644
index 0000000..52e822b
--- /dev/null
+++ b/assets/mats/shader_sky.tres
@@ -0,0 +1,90 @@
+[gd_resource type="ShaderMaterial" load_steps=9 format=3 uid="uid://la1c3g26n2xv"]
+
+[ext_resource type="Shader" path="res://assets/mats/sky.gdshader" id="1_re4p3"]
+[ext_resource type="Texture2D" uid="uid://11wgfnak257h" path="res://assets/textures/base-noise.png" id="2_mnx47"]
+
+[sub_resource type="FastNoiseLite" id="FastNoiseLite_i60uw"]
+noise_type = 3
+frequency = 0.001
+fractal_type = 2
+fractal_octaves = 1
+cellular_distance_function = 3
+cellular_return_type = 0
+
+[sub_resource type="NoiseTexture2D" id="NoiseTexture_uhc2h"]
+width = 1024
+height = 1024
+in_3d_space = true
+seamless = true
+noise = SubResource("FastNoiseLite_i60uw")
+
+[sub_resource type="FastNoiseLite" id="FastNoiseLite_1y10v"]
+
+[sub_resource type="NoiseTexture2D" id="NoiseTexture_vkbkn"]
+width = 1024
+height = 1024
+in_3d_space = true
+seamless = true
+noise = SubResource("FastNoiseLite_1y10v")
+
+[sub_resource type="FastNoiseLite" id="FastNoiseLite_deuf6"]
+noise_type = 2
+frequency = 0.037
+fractal_type = 0
+fractal_octaves = 1
+fractal_weighted_strength = 1.0
+cellular_distance_function = 1
+cellular_return_type = 3
+
+[sub_resource type="NoiseTexture2D" id="NoiseTexture_d3r0e"]
+width = 2048
+height = 2048
+seamless = true
+noise = SubResource("FastNoiseLite_deuf6")
+
+[resource]
+shader = ExtResource("1_re4p3")
+shader_parameter/cloud_edge_day_color = Color(0.9, 0.9, 0.9, 1)
+shader_parameter/cloud_main_day_color = Color(1, 1, 1, 1)
+shader_parameter/cloud_edge_night_color = Color(0.15, 0.19, 0.25, 1)
+shader_parameter/cloud_main_night_color = Color(0.15, 0.16, 0.2, 1)
+shader_parameter/cloud_speed_1 = 0.1
+shader_parameter/cloud_speed_2 = 0.1
+shader_parameter/cloud_speed_3 = 0.1
+shader_parameter/cloud_scale_1 = 0.1
+shader_parameter/cloud_scale_2 = 0.074
+shader_parameter/cloud_scale_3 = 0.075
+shader_parameter/cloud_distortion = 1.95
+shader_parameter/cloud_strength = 1.0
+shader_parameter/cloud_cutoff = 0.013
+shader_parameter/cloud_fuzziness = 1.0
+shader_parameter/cloud_noise1 = SubResource("NoiseTexture_uhc2h")
+shader_parameter/cloud_noise2 = SubResource("NoiseTexture_vkbkn")
+shader_parameter/day_bottom_color = Color(0.4, 1, 1, 1)
+shader_parameter/day_top_color = Color(0, 0.8, 1, 1)
+shader_parameter/offset_horizon = 0.4
+shader_parameter/horizon_intensity = -0.443
+shader_parameter/sun_set = Color(0.56, 0.24, 0, 1)
+shader_parameter/horizon_color_day = Color(0.57, 0.53, 0.26, 1)
+shader_parameter/horizon_color_night = Color(0.09, 0.16, 0.04, 1)
+shader_parameter/moon_color = Color(1, 1, 1, 1)
+shader_parameter/moon_radius = 0.1
+shader_parameter/moon_crescent = -0.085
+shader_parameter/dark_falloff = 3.915
+shader_parameter/night_bottom_color = Color(0, 0, 0.2, 1)
+shader_parameter/night_top_color = Color(0, 0, 0, 1)
+shader_parameter/stars_speed = 0.02
+shader_parameter/stars_cutoff = 0.744
+shader_parameter/stars_sky_color = Color(0, 0.11, 0.05, 1)
+shader_parameter/offset_stars = 0.015
+shader_parameter/stars_intensity = -2.998
+shader_parameter/star_falloff = 1.485
+shader_parameter/stars_fade_modulation = 0.91
+shader_parameter/stars_texture = SubResource("NoiseTexture_d3r0e")
+shader_parameter/base_noise = ExtResource("2_mnx47")
+shader_parameter/sun_color = Color(1, 1, 1, 1)
+shader_parameter/sun_radius = 0.4
+shader_parameter/flat_sun = true
+shader_parameter/enable_horizon_fade = true
+shader_parameter/horizon_fade_size = 0.2
+shader_parameter/horizon_fade_blend = 0.2
diff --git a/assets/mats/sky.gdshader b/assets/mats/sky.gdshader
new file mode 100644
index 0000000..591990b
--- /dev/null
+++ b/assets/mats/sky.gdshader
@@ -0,0 +1,159 @@
+// Shader Code origin from here: https://www.patreon.com/posts/making-stylized-27402644 by MinionsArt
+
+shader_type sky;
+render_mode use_half_res_pass;
+
+// Horizon
+group_uniforms horizon;
+uniform float offset_horizon : hint_range(-1.0, 1.0, 0.001) = 0.236;
+uniform float horizon_intensity : hint_range(-10.0, 5.0, 0.001) = -0.443;
+uniform vec4 sun_set : source_color = vec4(0.56, 0.24, 0.0, 1.0);
+uniform vec4 horizon_color_day : source_color = vec4(0.57, 0.53, 0.26, 1.0);
+uniform vec4 horizon_color_night : source_color = vec4(0.09, 0.16, 0.04, 1.0);
+
+// Sun
+group_uniforms sun;
+uniform vec4 sun_color : source_color = vec4(1.0);
+uniform float sun_radius : hint_range(0.0, 2.0, 0.001) = 0.2;
+uniform bool flat_sun = true;
+
+// Moon
+group_uniforms moon;
+uniform vec4 moon_color : source_color = vec4(1.0);
+uniform float moon_radius : hint_range(0.0, 2.0, 0.01) = 0.05;
+// negative: crescent on right side
+// positive: crescent on left side
+uniform float moon_crescent : hint_range(-0.3, 0.3, 0.001) = -0.024;
+uniform float dark_falloff : hint_range(1.0, 6.0, 0.001) = 3.915;
+
+// Sun and Moon Horizon fade parameters
+group_uniforms sun_moon_fade;
+uniform bool enable_horizon_fade = true;
+uniform float horizon_fade_size = 0.2;
+uniform float horizon_fade_blend = 0.1;
+
+// Day Background Colors
+group_uniforms day_bg_color;
+uniform vec4 day_bottom_color : source_color = vec4(0.4, 1.0, 1.0, 1.0);
+uniform vec4 day_top_color : source_color = vec4(0.0, 0.8, 1.0, 1.0);
+
+// Night Background Colors
+group_uniforms night_bg_color;
+uniform vec4 night_bottom_color : source_color = vec4(0.0, 0.0, 0.2, 1.0);
+uniform vec4 night_top_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
+
+// stars
+group_uniforms stars;
+uniform sampler2D stars_texture : hint_default_black;
+uniform sampler2D base_noise : hint_default_black;
+uniform float stars_speed : hint_range(0.0, 1.0, 0.001) = 0.2;
+uniform float stars_cutoff : hint_range(0.0, 1.0, 0.001) = 0.702;
+uniform vec4 stars_sky_color : source_color = vec4(0.0, 0.11, 0.05, 1);
+uniform float offset_stars : hint_range(-2.0, 2.0, 0.001) = 0.083;
+uniform float stars_intensity : hint_range(-10.0, 10.0, 0.001) = -2.829;
+uniform float star_falloff : hint_range(1.0, 10.0, 0.001) = 1.79;
+uniform float stars_fade_modulation : hint_range(-1.80, 1.80, 0.001) = 0.91;
+
+// Cloud stuff
+group_uniforms clouds;
+uniform sampler2D cloud_noise1 : hint_default_black;
+uniform sampler2D cloud_noise2 : hint_default_black;
+uniform vec4 cloud_edge_day_color : source_color = vec4(0.9, 0.9, 0.9, 1.0);
+uniform vec4 cloud_main_day_color : source_color = vec4(1.0);
+uniform vec4 cloud_edge_night_color : source_color = vec4(0.15, 0.19, 0.25, 1.0);
+uniform vec4 cloud_main_night_color : source_color = vec4(0.15, 0.16, 0.20, 1.0);
+uniform float cloud_speed_1 = 0.01;
+uniform float cloud_speed_2 = 0.02;
+uniform float cloud_speed_3 = 0.02;
+uniform float cloud_scale_1 = 0.425;
+uniform float cloud_scale_2 = 0.074;
+uniform float cloud_scale_3 = 0.075;
+uniform float cloud_distortion = 1.95;
+uniform float cloud_strength = 1.0;
+uniform float cloud_cutoff = 0.013;
+uniform float cloud_fuzziness = 0.261;
+
+void sky() {
+ // get skyUV to place the sun and the moon
+ vec2 skyUV = EYEDIR.xz / EYEDIR.y;
+
+ // Unused variable? Removing this unneccessary texture sample
+// float base_n = texture(base_noise, (skyUV - TIME) * base_noise_scale).x;
+
+ // get the middle -> abs of the EYEDIR to get the horizon
+ float horizon = abs((EYEDIR.y * horizon_intensity) - offset_horizon);
+ vec3 horizonGlow = clamp((1.0 - horizon * 5.0) * clamp(LIGHT0_DIRECTION.y * 10.0, 0.0, 1.0), 0.0, 1.0) * horizon_color_day.rgb;//
+ vec3 horizonGlowNight = clamp((1.0 - horizon * dark_falloff) * clamp( - LIGHT0_DIRECTION.y * 10.0, 0.0, 1.0), 0.0, 1.0) * horizon_color_night.rgb;//
+ horizonGlow += horizonGlowNight;
+
+ // horizon glow / sunset/ -rise
+ float sunset = clamp((1.0 - horizon) * clamp(LIGHT0_DIRECTION.y * 5.0, 0.0, 1.0), 0.0, 1.0);
+ vec3 sunsetColoured = sunset * sun_set.rgb;
+
+ // sun creation
+ float sun = distance(EYEDIR.xyz, LIGHT0_DIRECTION);
+ float sunDisc = 1.0 - clamp(sun / sun_radius, 0.0, 1.0);
+
+ // option to render flat sun
+// if (flat_sun == true) {
+// sunDisc = roundEven(sunDisc);
+// }
+ // The if statement above is technically part of a single GPU wavefront cycle,
+ // So its a special case where using an if statement doesn't cost too much perf
+ // But using a lerp/mix looks cooler ;)
+ // ...and might be slightly faster too ig, not by much tho
+ sunDisc = mix(sunDisc, roundEven(sunDisc), float(flat_sun));
+
+ // moon creation
+ float moon = distance(EYEDIR.xyz, - LIGHT0_DIRECTION);
+ float crescentMoon = distance(vec3(EYEDIR.x + moon_crescent, EYEDIR.yz), - LIGHT0_DIRECTION);
+ float crescentMoonDisc = 1.0 - (crescentMoon / moon_radius);
+ crescentMoonDisc = clamp(crescentMoonDisc * 50.0, 0.0, 1.0);
+ float moonDisc = 1.0 - (moon / moon_radius);
+ moonDisc = clamp(moonDisc * 50.0, 0.0, 1.0);
+ moonDisc = clamp(moonDisc - crescentMoonDisc, 0.0, 1.0);
+
+ // combine sun and moon
+ float top_mask = step(0.0, EYEDIR.y) * horizon;
+ top_mask = smoothstep(horizon_fade_size, horizon_fade_size + horizon_fade_blend, top_mask);
+ top_mask = mix(1.0, top_mask, float(enable_horizon_fade));
+ vec3 sunAndMoon = (sunDisc * sun_color.rgb) + (moonDisc * moon_color.rgb);
+ sunAndMoon *= top_mask;
+
+ // stars
+ float stars_parameters = abs((EYEDIR.y * stars_intensity) - offset_stars) * step(0.0, EYEDIR.y) * star_falloff;
+ vec3 stars = texture(stars_texture, (skyUV * stars_parameters) + (stars_speed * (TIME / 30.0))).rgb;
+ float stars_zenith = clamp(-LIGHT0_DIRECTION.y, 0.0, 1.0);
+ stars *= stars_zenith + abs(stars_zenith - stars_fade_modulation);
+ stars = step(stars_cutoff, stars);
+ stars += stars_sky_color.rgb;
+
+ //Sky Background Gradient
+ // day color gradient
+ vec3 gradientDay = mix(day_bottom_color.rgb, day_top_color.rgb, clamp(EYEDIR.y, 0.0, 1.0));
+ // night color gradient
+ vec3 gradientNight = mix(night_bottom_color.rgb, night_top_color.rgb, clamp(EYEDIR.y, 0.0, 1.0));
+ vec3 skyGradients = mix(gradientNight, gradientDay, clamp(LIGHT0_DIRECTION.y, 0.0, 1.0));
+
+ vec3 sky = skyGradients + sunAndMoon + sunsetColoured + stars + horizonGlow;
+
+
+ // Clouds
+ // UV space illusion
+ // (I have no idea how MinionsArt learned how to do this but its amazing)
+ vec2 cloud_uv = EYEDIR.xz / EYEDIR.y;
+ // Sample Noise at different levels
+ float bn = texture(base_noise, (cloud_uv - TIME * cloud_speed_1) * cloud_scale_1).r;
+ float cn1 = texture(cloud_noise1, ((cloud_uv + bn * cloud_distortion) - TIME * cloud_speed_2) * cloud_scale_2).r;
+ float cn2 = texture(cloud_noise2, ((cloud_uv + cn1 * cloud_strength) - TIME * cloud_speed_3) * cloud_scale_3).r;
+ // Combine noise and chop it up
+ float fc = clamp(cn1 * cn2, 0.0, 1.0) * clamp(EYEDIR.y, 0.0, 1.0);
+ float cc = smoothstep(cloud_cutoff, cloud_cutoff + cloud_fuzziness, fc);
+ // Mix colors according to time of day
+ vec4 cloud_color_day = mix(cloud_edge_day_color, cloud_main_day_color, cc);
+ vec4 cloud_color_night = mix(cloud_edge_night_color, cloud_main_night_color, cc);
+ float linear_day_to_night = LIGHT0_DIRECTION.y * 0.5 + 0.5;
+ vec4 cloud_color = mix(cloud_color_night, cloud_color_day, linear_day_to_night);
+
+ COLOR = mix(sky, cloud_color.rgb, cc * cloud_color.a);
+} \ No newline at end of file
diff --git a/assets/mats/support.tres b/assets/mats/support.tres
index 3d7b67d..7b2c681 100644
--- a/assets/mats/support.tres
+++ b/assets/mats/support.tres
@@ -1,7 +1,8 @@
-[gd_resource type="StandardMaterial3D" load_steps=2 format=3]
+[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bk4sxd2prmmom"]
[ext_resource type="Texture2D" uid="uid://b1re5kwpgdg07" path="res://assets/textures/support.png" id="1_0m2od"]
[resource]
albedo_texture = ExtResource("1_0m2od")
uv1_scale = Vector3(0.2, 0.2, 0.2)
+texture_filter = 0
diff --git a/assets/textures/base-noise.png b/assets/textures/base-noise.png
new file mode 100644
index 0000000..8455c4f
--- /dev/null
+++ b/assets/textures/base-noise.png
Binary files differ
diff --git a/assets/textures/base-noise.png.import b/assets/textures/base-noise.png.import
new file mode 100644
index 0000000..f949462
--- /dev/null
+++ b/assets/textures/base-noise.png.import
@@ -0,0 +1,36 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://11wgfnak257h"
+path.s3tc="res://.godot/imported/base-noise.png-1465006bf87670e88934396a47068ff4.s3tc.ctex"
+path.etc2="res://.godot/imported/base-noise.png-1465006bf87670e88934396a47068ff4.etc2.ctex"
+metadata={
+"imported_formats": ["s3tc", "etc2"],
+"vram_texture": true
+}
+
+[deps]
+
+source_file="res://assets/textures/base-noise.png"
+dest_files=["res://.godot/imported/base-noise.png-1465006bf87670e88934396a47068ff4.s3tc.ctex", "res://.godot/imported/base-noise.png-1465006bf87670e88934396a47068ff4.etc2.ctex"]
+
+[params]
+
+compress/mode=2
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=true
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/assets/textures/grass.png b/assets/textures/grass.png
index 0e30119..5734f9d 100644
--- a/assets/textures/grass.png
+++ b/assets/textures/grass.png
Binary files differ
diff --git a/assets/textures/support.png b/assets/textures/support.png
index cf69f27..f1681d2 100644
--- a/assets/textures/support.png
+++ b/assets/textures/support.png
Binary files differ
diff --git a/default_env.tres b/default_env.tres
index e456854..7310986 100644
--- a/default_env.tres
+++ b/default_env.tres
@@ -1,26 +1,18 @@
-[gd_resource type="Environment" load_steps=5 format=3 uid="uid://biwshm46yl62v"]
+[gd_resource type="Environment" load_steps=3 format=3 uid="uid://biwshm46yl62v"]
-[sub_resource type="Gradient" id="Gradient_dslwg"]
+[ext_resource type="Material" uid="uid://la1c3g26n2xv" path="res://assets/mats/shader_sky.tres" id="1_jcf87"]
-[sub_resource type="GradientTexture1D" id="GradientTexture1D_gewg2"]
-gradient = SubResource("Gradient_dslwg")
-
-[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_57jkl"]
-sky_top_color = Color(0.282353, 0.372549, 1, 1)
-sky_horizon_color = Color(0.427451, 0.658824, 1, 1)
-sky_curve = 0.204906
-ground_bottom_color = Color(0.427451, 0.658824, 1, 1)
-ground_horizon_color = Color(0.427451, 0.658824, 1, 1)
-ground_curve = 13.0515
-
-[sub_resource type="Sky" id="Sky_c7ivh"]
-sky_material = SubResource("ProceduralSkyMaterial_57jkl")
-process_mode = 1
+[sub_resource type="Sky" id="Sky_r1yiu"]
+sky_material = ExtResource("1_jcf87")
[resource]
background_mode = 2
-sky = SubResource("Sky_c7ivh")
+sky = SubResource("Sky_r1yiu")
ambient_light_source = 3
ambient_light_color = Color(0.87451, 0.87451, 0.815686, 1)
-volumetric_fog_density = 1.0
-adjustment_color_correction = SubResource("GradientTexture1D_gewg2")
+reflected_light_source = 2
+glow_enabled = true
+fog_light_color = Color(0.388235, 0.172549, 0.235294, 1)
+fog_density = 0.1832
+fog_height = -638.24
+fog_height_density = 0.8369
diff --git a/main.tscn b/main.tscn
index a816bf4..234017b 100644
--- a/main.tscn
+++ b/main.tscn
@@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://main.gd" id="1_cps4g"]
[ext_resource type="Environment" uid="uid://biwshm46yl62v" path="res://default_env.tres" id="1_rbfsw"]
[ext_resource type="CameraAttributesPractical" uid="uid://nhsovwj5hjip" path="res://cam.tres" id="2_rymfk"]
-[ext_resource type="Material" path="res://assets/mats/grass.tres" id="3_iiti7"]
+[ext_resource type="Material" uid="uid://bdyn312e6c3ll" path="res://assets/mats/grass.tres" id="3_iiti7"]
[ext_resource type="Script" path="res://cam.gd" id="4_u07o8"]
[ext_resource type="PackedScene" uid="uid://dyd5mqhgu6qfv" path="res://assets/cars/kenney_sedan/sedan.tscn" id="6_1vlt4"]
[ext_resource type="PackedScene" uid="uid://clw61td2wh84w" path="res://scenes/track.tscn" id="6_u5ece"]
@@ -22,10 +22,6 @@ size = Vector2(5000, 5000)
[node name="main" type="Node3D"]
script = ExtResource("1_cps4g")
-[node name="Sun" type="DirectionalLight3D" parent="."]
-transform = Transform3D(0.261981, -0.791013, -0.55287, 0.791617, -0.15154, 0.591927, -0.552004, -0.592735, 0.586479, 0, 37.0187, 0)
-directional_shadow_mode = 0
-
[node name="Env" type="WorldEnvironment" parent="."]
environment = ExtResource("1_rbfsw")
camera_attributes = ExtResource("2_rymfk")
@@ -44,16 +40,13 @@ mesh = SubResource("PlaneMesh_ta0cd")
transform = Transform3D(-0.718418, -0.318909, -0.618201, 0.111279, -0.92996, 0.350416, -0.686653, 0.182953, 0.703588, -7.07504, 13.1712, 16.3801)
far = 400.0
script = ExtResource("4_u07o8")
-follow_this = NodePath("../Car/Sedan")
+follow_this = NodePath("../Sedan")
target_distance = 9.0
target_height = 5.0
-[node name="Car" type="Node3D" parent="."]
+[node name="Sedan" parent="." instance=ExtResource("6_1vlt4")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 2, 100)
-[node name="Sedan" parent="Car" instance=ExtResource("6_1vlt4")]
-show_debug = true
-
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer"]
@@ -82,34 +75,20 @@ text = "龍 0km/h"
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("10_fu5aw")
-car = NodePath("../../../../Car/Sedan")
+car = NodePath("../../../../Sedan")
-[node name="MiniMap" type="Line2D" parent="CanvasLayer" node_paths=PackedStringArray("track")]
-position = Vector2(200, 150)
-default_color = Color(0.588235, 0.588235, 0.588235, 0.807843)
+[node name="MiniMap" type="Line2D" parent="CanvasLayer" node_paths=PackedStringArray("track", "car")]
+position = Vector2(300, 145)
+points = PackedVector2Array(-66, -46, 128, 3, -55, 150, -84, -24)
+default_color = Color(0.588235, 0.588235, 0.588235, 0.537255)
joint_mode = 2
antialiased = true
script = ExtResource("9_17iea")
track = NodePath("../../Track")
+car = NodePath("../../Sedan")
+player_color = Color(1, 0.388235, 0.321569, 0.803922)
[node name="Track" parent="." instance=ExtResource("6_u5ece")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
curve = ExtResource("12_5lojs")
track = ExtResource("13_pjowj")
-
-[node name="Road" parent="Track" index="0"]
-polygon = PackedVector2Array(-20, 0, -20, -0.1, 20, -0.1, 20, 0)
-
-[node name="CollisionShape" parent="Track" index="1"]
-polygon = PackedVector2Array(-23, 0, 23, 0, 23, 5, 26, 5, 26, -1, -26, -1, -26, 5, -23, 5)
-
-[node name="Rail-L" parent="Track" index="2"]
-polygon = PackedVector2Array(23, 0.5, 22.95, 0.47, 22.95, 0.43, 23, 0.4, 23, 0.55, 22.95, 0.32, 22.95, 0.28, 23, 0.25, 23.05, 0.25, 23.05, 0.5)
-
-[node name="Rail-R" parent="Track" index="3"]
-polygon = PackedVector2Array(-23, 0.5, -22.95, 0.47, -22.95, 0.43, -23, 0.4, -23, 0.55, -22.95, 0.32, -22.95, 0.28, -23, 0.25, -23.05, 0.25, -23.05, 0.5)
-
-[node name="Support" parent="Track" index="4"]
-polygon = PackedVector2Array(-22, -0.17, 22, -0.17, 25.1, -2, -25, -2)
-
-[editable path="Track"]
diff --git a/scenes/track-base.gd b/scenes/track-base.gd
index 5ab1bb5..a320614 100644
--- a/scenes/track-base.gd
+++ b/scenes/track-base.gd
@@ -2,6 +2,7 @@
extends Path3D
class_name TrackLoader
+@export_group("Track")
@export var track: TrackResource = null:
set(new_track):
if track != new_track:
@@ -20,8 +21,9 @@ class_name TrackLoader
@onready var rail_l := $"Rail-L" as CSGPolygon3D
@onready var rail_r := $"Rail-R" as CSGPolygon3D
@onready var collision := $CollisionShape as CSGPolygon3D
+@onready var sun := $Sun as DirectionalLight3D
-var is_dirty = true
+var is_dirty := true
func vec(x := 0.0, y := 0.0) -> Vector2:
return Vector2(x, y)
@@ -29,24 +31,28 @@ func vec(x := 0.0, y := 0.0) -> Vector2:
func _update():
if !is_dirty or !track or !track.track:
- # curve = null
+ # curve = null # editor freezes with this, idk why
return
curve = track.track
curve.set_point_tilt(0, PI/2)
curve.set_point_tilt(curve.get_point_count() - 1, 0.0)
+ sun.rotation_degrees.x = (track.sun_x)
+ sun.rotation_degrees.y = (track.sun_y)
+
+
# update our track
- var thw: float = track.track_width * 0.5 # track half width
+ var thw := track.track_width * 0.5 # track half width
road.polygon = PackedVector2Array([vec(-thw), vec(-thw, -0.1), vec(thw, -0.1), vec(thw)])
support.polygon = PackedVector2Array([
- vec(-thw - 2.0, -0.17),
- vec( thw + 2.0, -0.17),
+ vec(-thw - 2.0, -1),
+ vec( thw + 2.0, -1),
vec( track.lower_support_width + 0.1, -track.support_height),
vec(-track.lower_support_width, -track.support_height)
])
# update our rails
- var rp: float = thw + track.rail_distance # rail position
+ var rp := thw + track.rail_distance # rail position
rail_l.polygon = PackedVector2Array([
vec(rp, 0.5),
vec(rp - 0.05, 0.47),
@@ -86,6 +92,9 @@ func _update():
c.set(7, Vector2(-rp, 5.0))
collision.polygon = c
+ # annd offset
+ position = track.offset
+
is_dirty = false
func _ready():
diff --git a/scenes/track.tscn b/scenes/track.tscn
index 7c3dfd1..bab3bde 100644
--- a/scenes/track.tscn
+++ b/scenes/track.tscn
@@ -1,13 +1,9 @@
-[gd_scene load_steps=6 format=3 uid="uid://clw61td2wh84w"]
+[gd_scene load_steps=5 format=3 uid="uid://clw61td2wh84w"]
[ext_resource type="Script" path="res://scenes/track-base.gd" id="1_ke7nx"]
-[ext_resource type="Texture2D" uid="uid://2fjjxft1ip57" path="res://assets/textures/road.png" id="1_q0215"]
+[ext_resource type="Material" uid="uid://be8pta62kxd2j" path="res://assets/mats/road.tres" id="2_2nntu"]
[ext_resource type="Material" uid="uid://dtpgjplswm6lr" path="res://assets/mats/rail.tres" id="2_3pcob"]
-[ext_resource type="Material" path="res://assets/mats/support.tres" id="3_4570s"]
-
-[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xw8xl"]
-albedo_texture = ExtResource("1_q0215")
-uv1_scale = Vector3(8, 8, 8)
+[ext_resource type="Material" uid="uid://bk4sxd2prmmom" path="res://assets/mats/support.tres" id="3_4570s"]
[node name="TrackLoader" type="Path3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.70198, -8.01861, -4.84379)
@@ -25,7 +21,7 @@ path_local = false
path_continuous_u = true
path_u_distance = 0.0
path_joined = true
-material = SubResource("StandardMaterial3D_xw8xl")
+material = ExtResource("2_2nntu")
[node name="CollisionShape" type="CSGPolygon3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.165113, 0)
@@ -84,4 +80,6 @@ path_u_distance = 1.0
path_joined = true
material = ExtResource("3_4570s")
+[node name="Sun" type="DirectionalLight3D" parent="."]
+
[connection signal="curve_changed" from="." to="." method="_on_curve_changed"]
diff --git a/track.gd b/track.gd
index d65df39..d5db94f 100644
--- a/track.gd
+++ b/track.gd
@@ -1,16 +1,26 @@
extends Resource
class_name TrackResource
+@export_group("Road")
## Width of road
-@export var track_width = 17.0
+@export var track_width := 17.0
## Distance between rails and road
-@export var rail_distance = 3.0
+@export var rail_distance := 3.0
## Support base width
-@export var lower_support_width = 15.0
+@export var lower_support_width := 15.0
## Height of supports
-@export var support_height = 8.0
+@export var support_height := 8.0
## Track curve
@export var track: Curve3D = null
+@export_subgroup("Barriers")
## Left barrier? (does not change collisions). see also [member right_barrier]
-@export var left_barrier = true
+@export var left_barrier := true
## Right barrier? (does not change collisions). see also [member left_barrier]
-@export var right_barrier = true \ No newline at end of file
+@export var right_barrier := true
+@export_group("Sun position")
+## Sun x rotation
+@export_range(-360, 360) var sun_x := -90
+## Sun y rotation ( its a game, the sun rotates around us )
+@export_range(-360, 360) var sun_y := 0
+@export_group("", "")
+## Offset
+@export var offset := Vector3.UP \ No newline at end of file
diff --git a/tracks/speedway_curve.tres b/tracks/speedway_curve.tres
index b6d833e..2523886 100644
--- a/tracks/speedway_curve.tres
+++ b/tracks/speedway_curve.tres
@@ -1,6 +1,7 @@
[gd_resource type="Curve3D" format=3 uid="uid://u2f56xx8h2re"]
[resource]
+bake_interval = 10.0
_data = {
"points": PackedVector3Array(110.965, 0, -2.66191, -100, 0, 0, -200, 0, 100, -100, 0, 0, 0, 0, 0, -200, 0, -100, 0, 0, 0, 100, 0, 0, 200, 0, -100, 100, 0, 0, 0, 0, 0, 200, 0, 100, 200, 0, 0, 0, 0, 0, -200, 0, 100),
"tilts": PackedFloat32Array(1.5708, 0, 0, 0, 0)
diff --git a/tracks/speedway_track.tres b/tracks/speedway_track.tres
index bb4a316..756fe7e 100644
--- a/tracks/speedway_track.tres
+++ b/tracks/speedway_track.tres
@@ -13,3 +13,6 @@ support_height = 2.0
track = ExtResource("2_33qpi")
left_barrier = true
right_barrier = true
+sun_x = -90
+sun_y = 0
+offset = Vector3(0, 1, 0)
diff --git a/ui/gears.gd b/ui/gears.gd
deleted file mode 100644
index aa54b08..0000000
--- a/ui/gears.gd
+++ /dev/null
@@ -1,10 +0,0 @@
-extends RichTextLabel
-
-@export var car: Node3D
-
-# assumes 6 gear + rev
-const F_STRING = "[center] [b]%s[/b][/center]"
-const GEARS: PackedStringArray = ["[color=#4682b4]N[/color]", "1", "2", "3", "4", "5", "6", "[color=#d84341]R[/color]"]
-
-# func _process(_delta: float) -> void:
-# text = F_STRING % GEARS[car.current_gear]
diff --git a/ui/map.gd b/ui/map.gd
index a182caa..fa6d737 100644
--- a/ui/map.gd
+++ b/ui/map.gd
@@ -1,11 +1,32 @@
extends Line2D
@export var track: TrackLoader
+@export var car: Node3D
+@export var player_color: Color
-# Called when the node enters the scene tree for the first time.
func _ready() -> void:
clear_points()
width = track.track.track_width
+ # am on the fence about outlining
+ # var outline := Line2D.new()
+ # outline.width = width + 10
+ # outline.default_color = Color.BLACK
+ # outline.show_behind_parent = true
+ # outline.antialiased = true
+ # outline.joint_mode = LINE_JOINT_ROUND
+ # add_child(outline)
for point_3d in track.curve.get_baked_points():
- var p := Vector2(point_3d.x, point_3d.z) / 2
+ var p := flatten(point_3d)
add_point(p)
+ # outline.add_point(p)
+
+
+func _process(_delta: float) -> void:
+ queue_redraw()
+
+func _draw() -> void:
+ var point := flatten(track.curve.get_closest_point(car.ball.global_position))
+ draw_circle(point, width / 2, player_color)
+
+func flatten(vec: Vector3) -> Vector2:
+ return Vector2(vec.x, vec.z)
diff --git a/ui/revs.gd b/ui/revs.gd
deleted file mode 100644
index 4704adc..0000000
--- a/ui/revs.gd
+++ /dev/null
@@ -1,7 +0,0 @@
-extends Label
-
-@export var f_string = " %drpm"
-@export var car: Node3D
-
-# func _process(_delta: float) -> void:
-# text = f_string % car.calculate_rpm()
diff --git a/ui/speedometer.gd b/ui/speedometer.gd
index 7f915f0..39ec8ca 100644
--- a/ui/speedometer.gd
+++ b/ui/speedometer.gd
@@ -1,6 +1,6 @@
extends Label
-@export var f_string = "龍 %0.1fkm/h"
+@export var f_string = "龍 %dkm/h"
@export var car: Node3D
func _process(_delta: float) -> void: